RE: Reporting an Exception message in a JSP.

2003-02-25 Thread David Bolsover
Agreed - but in the UK we wouldn't stop at 117v  - 240v minimum :).

db

> -Original Message-
> From: Mark Galbreath [mailto:[EMAIL PROTECTED]
> Sent: 25 February 2003 15:22
> To: 'Struts Users Mailing List'
> Subject: RE: Reporting an Exception message in a JSP.
> 
> 
> I've always found electric shock to be effective.  There's nothing like that
> ol' 117v/60Hz AC wake-up call to let a user know not to do that again!
> 
> Seriously, you can add a returned exception to the errors array in the
> Action class, then display it with .
> 
> Mark
> 
> -Original Message-
> From: ROSSEL Olivier [mailto:[EMAIL PROTECTED] 
> Sent: Tuesday, February 25, 2003 10:03 AM
> 
> what's the nicest way to show to the user the error message that I get from
> my SQLException?
> 
> 
> 
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Reporting an Exception message in a JSP.

2003-02-25 Thread Paul Yunusov
On Tuesday 25 February 2003 10:03 am, ROSSEL Olivier wrote:
> I want to display the error message of an SQLException
> in my JSP.
>
> At first, I tried to set an ActionError with this message and
> to display it via .
> It does not work because ActionError accepts as an input
> string the key of a property.
>
> So what's the nicest way to show to the user the error message
> that I get from my SQLException ?

If you use Struts 1.1, declare an  under  or an 
 in your struts config xml file. You can specify a JSP page to 
forward the request to within the exception element.

You may need to define an ExceptionHandler class that will be passed request, 
response and exception objects if an Action throws an exception. Build any 
response there that's more complex than merely forwarding to a JSP.

Read section 4.5 of the wonderful Struts user guide:
http://jakarta.apache.org/struts/userGuide and read the struts config file's 
DTD - very revealing texts.

Paul

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: Reporting an Exception message in a JSP.

2003-02-25 Thread pqin
Solution 1:

- Add error to ActionMessage.
- Display the above message as a hidden field on the same page.
- Meanwhile, display a friendly message to user on the same page.

Solution 2:

- log exception to a file.
- display friendly message to user on the same page.


Regards,
 
 
PQ
 
"This Guy Thinks He Knows Everything"
"This Guy Thinks He Knows What He Is Doing"

-Original Message-
From: Robert S. Sfeir [mailto:[EMAIL PROTECTED] 
Sent: February 25, 2003 10:30 AM
To: Struts Users Mailing List
Subject: Re: Reporting an Exception message in a JSP.


On Tuesday, Feb 25, 2003, at 10:14 US/Eastern, David Graham wrote:

> Well, I would never show my user an error message from some low level 
> system such as the database.  If you really want them to see this info 
> you could define a message key as anything={0} and substitute your SQL 
> message.  I highly discourage this but it's an option.

True but in my case I find it sometimes easier to turn on debugging 
from my browser on a live app to see what's causing the exception the 
user is seeing without having to look at logs or anything, so while the 
user never sees this error in normal processing, I can see the 
exception when trying to debug and figure out what's going on on a live 
app.

I don't know if this was the original poster's intent though.


R

--
Robert S. Sfeir
Senior Java Engineer
Codepuccino, Inc.
[EMAIL PROTECTED]

definition - Codepuccino n:
A Little JSP mixed with lots of Java, usually served with Servlets, a 
Datasource, a sprinkle of XML, and sometimes EJB.  (See Great MVC 
Frameworks)


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Re: Reporting an Exception message in a JSP.

2003-02-25 Thread Ian Hunter
If you can, make it based on some user token that only you would have.

- Original Message -
From: "John Espey" <[EMAIL PROTECTED]>
To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
Sent: Tuesday, February 25, 2003 10:35 AM
Subject: RE: Reporting an Exception message in a JSP.


> What do you think of printing that exception out in comment, so you can
view
> the source to see the exception but not have to worry about turning it on
or
> off?
>
> > -Original Message-
> > From: Robert S. Sfeir [mailto:[EMAIL PROTECTED]
> > Sent: Tuesday, February 25, 2003 9:30 AM
> > To: Struts Users Mailing List
> > Subject: Re: Reporting an Exception message in a JSP.
> >
> >
> >
> > On Tuesday, Feb 25, 2003, at 10:14 US/Eastern, David Graham wrote:
> >
> > > Well, I would never show my user an error message from some low level
> > > system such as the database.  If you really want them to see this info
> > > you could define a message key as anything={0} and substitute your SQL
> > > message.  I highly discourage this but it's an option.
> >
> > True but in my case I find it sometimes easier to turn on debugging
> > from my browser on a live app to see what's causing the exception the
> > user is seeing without having to look at logs or anything, so while the
> > user never sees this error in normal processing, I can see the
> > exception when trying to debug and figure out what's going on on a live
> > app.
> >
> > I don't know if this was the original poster's intent though.
> >
> >
> > R
> >
> > --
> > Robert S. Sfeir
> > Senior Java Engineer
> > Codepuccino, Inc.
> > [EMAIL PROTECTED]
> >
> > definition - Codepuccino n:
> > A Little JSP mixed with lots of Java, usually served with Servlets, a
> > Datasource, a sprinkle of XML, and sometimes EJB.  (See Great MVC
> > Frameworks)
> >
> >
> > -
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
>
>
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: Reporting an Exception message in a JSP.

2003-02-25 Thread pqin
I usually log SQLExceptions in log file and display "An unexpected error
occurred, please contact your sys admin".

Regards,
 
 
PQ
 
"This Guy Thinks He Knows Everything"
"This Guy Thinks He Knows What He Is Doing"

-Original Message-
From: John Espey [mailto:[EMAIL PROTECTED] 
Sent: February 25, 2003 10:19 AM
To: Struts Users Mailing List
Subject: RE: Reporting an Exception message in a JSP.

Quick questiondo you really want the user to see a SQLException message?

Assuming that is really what you want, there are constructors for AE that
take a key and up to four objects that will be substituted in the error
value that is specified for the key.  The key and value appear in
ApplicationResources.properties.  So you could do the following in your
action:
catch (SQLException e)
{
ActionErrors errors = new ActionErrors();
errors.add(ActionErrors.GLOBAL_ERROR, new
ActionError("sql.exception",
e.getMessage()));
saveErrors(request, errors);
return mapping.findForward("systemexception");
}


and then have this entry:
sql.exception=A database access error occurred.  {0}

The error message should then have the exception's message appear in it in
your error page.

Hope this helps



> -Original Message-
> From: ROSSEL Olivier [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, February 25, 2003 9:03 AM
> To: '[EMAIL PROTECTED]'
> Subject: Reporting an Exception message in a JSP.
>
>
> I want to display the error message of an SQLException
> in my JSP.
>
> At first, I tried to set an ActionError with this message and
> to display it via .
> It does not work because ActionError accepts as an input
> string the key of a property.
>
> So what's the nicest way to show to the user the error message
> that I get from my SQLException ?
>
>
> ---cut here---
>
>
> This e-mail is intended only for the above addressee. It may contain
> privileged information. If you are not the addressee you must not copy,
> distribute, disclose or use any of the information in it. If you have
> received it in error please delete it and immediately notify the sender.
> Security Notice: all e-mail, sent to or from this address, may be
> accessed by someone other than the recipient, for system management and
> security reasons. This access is controlled under Regulation of
> Investigatory Powers Act 2000, Lawful Business Practises.
>
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


RE: Reporting an Exception message in a JSP.

2003-02-25 Thread John Espey
What do you think of printing that exception out in comment, so you can view
the source to see the exception but not have to worry about turning it on or
off?

> -Original Message-
> From: Robert S. Sfeir [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, February 25, 2003 9:30 AM
> To: Struts Users Mailing List
> Subject: Re: Reporting an Exception message in a JSP.
>
>
>
> On Tuesday, Feb 25, 2003, at 10:14 US/Eastern, David Graham wrote:
>
> > Well, I would never show my user an error message from some low level
> > system such as the database.  If you really want them to see this info
> > you could define a message key as anything={0} and substitute your SQL
> > message.  I highly discourage this but it's an option.
>
> True but in my case I find it sometimes easier to turn on debugging
> from my browser on a live app to see what's causing the exception the
> user is seeing without having to look at logs or anything, so while the
> user never sees this error in normal processing, I can see the
> exception when trying to debug and figure out what's going on on a live
> app.
>
> I don't know if this was the original poster's intent though.
>
>
> R
>
> --
> Robert S. Sfeir
> Senior Java Engineer
> Codepuccino, Inc.
> [EMAIL PROTECTED]
>
> definition - Codepuccino n:
> A Little JSP mixed with lots of Java, usually served with Servlets, a
> Datasource, a sprinkle of XML, and sometimes EJB.  (See Great MVC
> Frameworks)
>
>
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Reporting an Exception message in a JSP.

2003-02-25 Thread Robert S. Sfeir
On Tuesday, Feb 25, 2003, at 10:14 US/Eastern, David Graham wrote:

Well, I would never show my user an error message from some low level 
system such as the database.  If you really want them to see this info 
you could define a message key as anything={0} and substitute your SQL 
message.  I highly discourage this but it's an option.
True but in my case I find it sometimes easier to turn on debugging 
from my browser on a live app to see what's causing the exception the 
user is seeing without having to look at logs or anything, so while the 
user never sees this error in normal processing, I can see the 
exception when trying to debug and figure out what's going on on a live 
app.

I don't know if this was the original poster's intent though.

R

--
Robert S. Sfeir
Senior Java Engineer
Codepuccino, Inc.
[EMAIL PROTECTED]
definition - Codepuccino n:
A Little JSP mixed with lots of Java, usually served with Servlets, a 
Datasource, a sprinkle of XML, and sometimes EJB.  (See Great MVC 
Frameworks)

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


RE: Reporting an Exception message in a JSP.

2003-02-25 Thread Mark Galbreath
I've always found electric shock to be effective.  There's nothing like that
ol' 117v/60Hz AC wake-up call to let a user know not to do that again!

Seriously, you can add a returned exception to the errors array in the
Action class, then display it with .

Mark

-Original Message-
From: ROSSEL Olivier [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, February 25, 2003 10:03 AM

what's the nicest way to show to the user the error message that I get from
my SQLException?



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: Reporting an Exception message in a JSP.

2003-02-25 Thread John Espey
Quick questiondo you really want the user to see a SQLException message?

Assuming that is really what you want, there are constructors for AE that
take a key and up to four objects that will be substituted in the error
value that is specified for the key.  The key and value appear in
ApplicationResources.properties.  So you could do the following in your
action:
catch (SQLException e)
{
ActionErrors errors = new ActionErrors();
errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("sql.exception",
e.getMessage()));
saveErrors(request, errors);
return mapping.findForward("systemexception");
}


and then have this entry:
sql.exception=A database access error occurred.  {0}

The error message should then have the exception's message appear in it in
your error page.

Hope this helps



> -Original Message-
> From: ROSSEL Olivier [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, February 25, 2003 9:03 AM
> To: '[EMAIL PROTECTED]'
> Subject: Reporting an Exception message in a JSP.
>
>
> I want to display the error message of an SQLException
> in my JSP.
>
> At first, I tried to set an ActionError with this message and
> to display it via .
> It does not work because ActionError accepts as an input
> string the key of a property.
>
> So what's the nicest way to show to the user the error message
> that I get from my SQLException ?
>
>
> ---cut here---
>
>
> This e-mail is intended only for the above addressee. It may contain
> privileged information. If you are not the addressee you must not copy,
> distribute, disclose or use any of the information in it. If you have
> received it in error please delete it and immediately notify the sender.
> Security Notice: all e-mail, sent to or from this address, may be
> accessed by someone other than the recipient, for system management and
> security reasons. This access is controlled under Regulation of
> Investigatory Powers Act 2000, Lawful Business Practises.
>
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: Reporting an Exception message in a JSP.

2003-02-25 Thread pqin
If you want to show your error message on the page where error occurs, there
is no easy way than .

Regards,
 
 
PQ
 
"This Guy Thinks He Knows Everything"
"This Guy Thinks He Knows What He Is Doing"

-Original Message-
From: ROSSEL Olivier [mailto:[EMAIL PROTECTED] 
Sent: February 25, 2003 10:03 AM
To: '[EMAIL PROTECTED]'
Subject: Reporting an Exception message in a JSP.

I want to display the error message of an SQLException
in my JSP.

At first, I tried to set an ActionError with this message and
to display it via .
It does not work because ActionError accepts as an input
string the key of a property.

So what's the nicest way to show to the user the error message
that I get from my SQLException ?


---cut here---


This e-mail is intended only for the above addressee. It may contain
privileged information. If you are not the addressee you must not copy,
distribute, disclose or use any of the information in it. If you have
received it in error please delete it and immediately notify the sender.
Security Notice: all e-mail, sent to or from this address, may be
accessed by someone other than the recipient, for system management and
security reasons. This access is controlled under Regulation of
Investigatory Powers Act 2000, Lawful Business Practises.

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Re: Reporting an Exception message in a JSP.

2003-02-25 Thread David Graham
Well, I would never show my user an error message from some low level system 
such as the database.  If you really want them to see this info you could 
define a message key as anything={0} and substitute your SQL message.  I 
highly discourage this but it's an option.

David





From: ROSSEL Olivier <[EMAIL PROTECTED]>
Reply-To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
To: "'[EMAIL PROTECTED]'" <[EMAIL PROTECTED]>
Subject: Reporting an Exception message in a JSP.
Date: Tue, 25 Feb 2003 16:03:12 +0100
I want to display the error message of an SQLException
in my JSP.
At first, I tried to set an ActionError with this message and
to display it via .
It does not work because ActionError accepts as an input
string the key of a property.
So what's the nicest way to show to the user the error message
that I get from my SQLException ?
---cut here---

This e-mail is intended only for the above addressee. It may contain
privileged information. If you are not the addressee you must not copy,
distribute, disclose or use any of the information in it. If you have
received it in error please delete it and immediately notify the sender.
Security Notice: all e-mail, sent to or from this address, may be
accessed by someone other than the recipient, for system management and
security reasons. This access is controlled under Regulation of
Investigatory Powers Act 2000, Lawful Business Practises.
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


_
Help STOP SPAM with the new MSN 8 and get 2 months FREE*  
http://join.msn.com/?page=features/junkmail

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


RE: Reporting an Exception message in a JSP.

2003-02-25 Thread Sri Sankaran
You can still use the fact that argument to the constructor of an ActionError is the 
key to resource.  You could set up your app resources with

some.key=Could not proceed because of {0} error

Then you can create the ActionError as

  new ActionError("some.key", exception.getMessage());

Sri

-Original Message-
From: ROSSEL Olivier [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, February 25, 2003 10:03 AM
To: '[EMAIL PROTECTED]'
Subject: Reporting an Exception message in a JSP.


I want to display the error message of an SQLException
in my JSP.

At first, I tried to set an ActionError with this message and to display it via 
. It does not work because ActionError accepts as an input string the 
key of a property.

So what's the nicest way to show to the user the error message that I get from my 
SQLException ?


---cut here---


This e-mail is intended only for the above addressee. It may contain privileged 
information. If you are not the addressee you must not copy, distribute, disclose or 
use any of the information in it. If you have received it in error please delete it 
and immediately notify the sender. Security Notice: all e-mail, sent to or from this 
address, may be accessed by someone other than the recipient, for system management 
and security reasons. This access is controlled under Regulation of Investigatory 
Powers Act 2000, Lawful Business Practises.

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]