RE: Help with Exception handling

2004-11-26 Thread Seetamraju, Uday
I don't like to let the exception go as is, since I need the stack trace.
Don't you wanna know what went wrong?

The following works wonderfully, -- I have :-


Note my key!

My system failure URL is mapped in web.xml to a simple JSP with customer 
service tel#.

public class MyExceptionHandlerAction extends ExceptionHandler {
... 
public ActionForward execute(Exception arg0, ExceptionConfig arg1,
ActionMapping arg2, ActionForm arg3, HttpServletRequest 
arg4,
HttpServletResponse arg5) throws ServletException {
return new ActionForward(arg1.getPath());
}

protected void logException(Exception arg0) {
super.logException(arg0);
logger.log(Level.SEVERE, this.getClass().getName()+ " is 
handling unexpected webapp exception : "+arg0);
arg0.printStackTrace();
}
}
> -Original Message-
> From: Wendy Smoak [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, November 17, 2004 6:32 PM
> To: Struts Users Mailing List
> Subject: Help with Exception handling
> 
> 
> I know I've tried this before, but so far I haven't gotten 
> all the pieces
> properly arranged so it works. :/
> 
> I currently have code like this in an Action:
> try {
>benId = loginDAO.getBenId( asurite );
> } catch ( TermsAcceptanceException ex ) {
>return mapping.findForward( "terms" );
> }
> 
> In struts-config.xml:
>   path="/denLogin"
> type="edu.asu.vpia.struts.DevilsDenLoginAction"
> name="loginForm"
> scope="request"
> validate="true"
> input="den.login.page">
>
>
> 
> 
> It's my impression that I don't need to catch the exception, 
> that I *should*
> be able to let Action.execute(...) throw it and the framework can be
> configured to deal appropriately with it.
> 
> So I took out this line:
>
> And put in:
>  type="edu.asu.dao.DAOException"
> path="/WEB-INF/error.jsp"
> key="error.dao.exception"/>
> 
> And I just get a JSP with a stack trace.  Although 
> TermsAcceptanceException
> extends DAOException, it doesn't go to error.jsp.
> 
> Two questions... what is the 'key' attribute of  
> used for, and
> can anyone tell what I'm doing wrong?
> 
> Thanks!
> -- 
> Wendy Smoak
> 
> 
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
>
 
 
 


 
The information contained in this message is intended only for the recipient, 
and may be a confidential attorney-client communication or may otherwise be 
privileged and confidential and protected from disclosure. If the reader of 
this message is not the intended recipient, or an employee or agent responsible 
for delivering this message to the intended recipient, please be aware that any 
dissemination or copying of this communication is strictly prohibited. If you 
have received this communication in error, please immediately notify us by 
replying to the message and deleting it from your computer.
 
Thank you,
 
Standard & Poor's
 


 

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



Re: Help with Exception handling

2004-11-18 Thread Wendy Smoak
From: "David G. Friedman" <[EMAIL PROTECTED]>
> Now, on the JSP issues, since you're trading control over to JSP's, can't
> you list the exception in your web.xml configuration file?  See the
> 'exception-type' in the solution under this url:
> http://www.jguru.com/faq/view.jsp?EID=457102

Probably, but then I couldn't use a Tiles definition for the 'path' it
should go to when the Exception is thrown.   Although right now I'm just
using 'error.jsp' it eventually needs to be a Tiles def.

From: "Bill Siggelkow"
> Struts exception handling *does* work correctly when it comes to
> inheritance; and your configuration looks correct. First, check the FQN
> (fully-qualified name) of your exception

Bill wins the prize.  Amazing what a good night's sleep and another set of
eyes will do for a problem... I missed one of the pieces of the package
name.  And it works!

Thanks also to Erik for explaining the 'key' attribute. :)

-- 
Wendy Smoak



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



Re: Help with Exception handling

2004-11-17 Thread Bill Siggelkow
Wendy,
Struts exception handling *does* work correctly when it comes to 
inheritance; and your configuration looks correct. First, check the FQN 
(fully-qualified name) of your exception -- if that's correct, I suggest 
you take out your handy-dandy debugger and set a breakpoint in the 
RequestProcessor. I think you will find that using the debugger is
(a) fun,
(b) educational, and
(c) fun ;)

-Bill Siggelkow
Wendy Smoak wrote:
I know I've tried this before, but so far I haven't gotten all the pieces
properly arranged so it works. :/
I currently have code like this in an Action:
try {
   benId = loginDAO.getBenId( asurite );
} catch ( TermsAcceptanceException ex ) {
   return mapping.findForward( "terms" );
}
In struts-config.xml:
 
   
   

It's my impression that I don't need to catch the exception, that I *should*
be able to let Action.execute(...) throw it and the framework can be
configured to deal appropriately with it.
So I took out this line:
   
And put in:

And I just get a JSP with a stack trace.  Although TermsAcceptanceException
extends DAOException, it doesn't go to error.jsp.
Two questions... what is the 'key' attribute of  used for, and
can anyone tell what I'm doing wrong?
Thanks!

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


Re: Help with Exception handling

2004-11-17 Thread Erik Weber
Sorry, I don't exactly know what you are doing wrong, but here is an 
example that shows what the "key" attribute is for:

From a struts-config.xml:
 
  
   
   
   
   

The "key" attribute to the "exception" element is a message resources 
key, in the bundle specified by the "bundle" attribute. In my 
"ExceptionMessages" properties file, I have:

broker.login.error.authFailure=Sorry, you entered the wrong password
You are correct that, in your Action's execute method, you simply throw 
the Exception (in my example, an AuthenticationException), and the 
framework will catch it (since handling has been configured).

In my JSP I have this:
  <%-- print exception messages if there are any, otherwise
print form validation error messages if there are 
any --%>
   
 
   


As someone pointed out in another Thread (I think it was Joe), my JSP 
code (logic:present) is not the most efficient, but it works. This 
prints the error message "Sorry, you entered the wrong password" at the 
top of the page if that message is present (if the Exception was thrown).

I have also used the "path" attribute in a global exception config, and 
it does work as expected. One thing I haven't done, however, is 
configure for a base class of the actual Exception. I always configure 
for the exact Exception class. So that could be it.

Hope this helps.
Erik


Wendy Smoak wrote:
I know I've tried this before, but so far I haven't gotten all the pieces
properly arranged so it works. :/
I currently have code like this in an Action:
   try {
  benId = loginDAO.getBenId( asurite );
   } catch ( TermsAcceptanceException ex ) {
  return mapping.findForward( "terms" );
   }
In struts-config.xml:

  
  
   
It's my impression that I don't need to catch the exception, that I *should*
be able to let Action.execute(...) throw it and the framework can be
configured to deal appropriately with it.
So I took out this line:
  
And put in:
   
And I just get a JSP with a stack trace.  Although TermsAcceptanceException
extends DAOException, it doesn't go to error.jsp.
Two questions... what is the 'key' attribute of  used for, and
can anyone tell what I'm doing wrong?
Thanks!
 

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


RE: Help with Exception handling

2004-11-17 Thread David G. Friedman
Wendy,

Damn, with a name like that it seemed like a resource or a Java code.  I'm
so used to the convention of starting a tiles definition with a period that
you bluffed me.

Now, on the JSP issues, since you're trading control over to JSP's, can't
you list the exception in your web.xml configuration file?  See the
'exception-type' in the solution under this url:
http://www.jguru.com/faq/view.jsp?EID=457102

Regards,
David

-Original Message-
From: Wendy Smoak [mailto:[EMAIL PROTECTED]
Sent: Wednesday, November 17, 2004 6:43 PM
To: Struts Users Mailing List
Subject: Re: Help with Exception handling


From: "David G. Friedman" <[EMAIL PROTECTED]>
> This looks interesting.  What is 'den.login.success'?  Is it a key in a
> resource file or a java class or just a flat file with a dot-notation
name?

It's a Tiles definition.

I'm sure I initially tried a Tiles def in the path attribute of the
 tag, and then switched to a plain old error.jsp when it didn't
work.  Unfortunately it still doesn't go there when the Exception is thrown,
it just shows a stack trace as though the error handling isn't working at
all.

I forgot to mention in the first message: I'm using Struts 1.2.5 .

Thanks for any ideas!
--
Wendy Smoak


-
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: Help with Exception handling

2004-11-17 Thread Wendy Smoak
From: "David G. Friedman" <[EMAIL PROTECTED]>
> This looks interesting.  What is 'den.login.success'?  Is it a key in a
> resource file or a java class or just a flat file with a dot-notation
name?

It's a Tiles definition.

I'm sure I initially tried a Tiles def in the path attribute of the
 tag, and then switched to a plain old error.jsp when it didn't
work.  Unfortunately it still doesn't go there when the Exception is thrown,
it just shows a stack trace as though the error handling isn't working at
all.

I forgot to mention in the first message: I'm using Struts 1.2.5 .

Thanks for any ideas!
-- 
Wendy Smoak


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



RE: Help with Exception handling

2004-11-17 Thread David G. Friedman
Wendy,

This looks interesting.  What is 'den.login.success'?  Is it a key in a
resource file or a java class or just a flat file with a dot-notation name?

Regards,
David

-Original Message-
From: Wendy Smoak [mailto:[EMAIL PROTECTED]
Sent: Wednesday, November 17, 2004 6:32 PM
To: Struts Users Mailing List
Subject: Help with Exception handling


I know I've tried this before, but so far I haven't gotten all the pieces
properly arranged so it works. :/

I currently have code like this in an Action:
try {
   benId = loginDAO.getBenId( asurite );
} catch ( TermsAcceptanceException ex ) {
   return mapping.findForward( "terms" );
}

In struts-config.xml:
 
   
   


It's my impression that I don't need to catch the exception, that I *should*
be able to let Action.execute(...) throw it and the framework can be
configured to deal appropriately with it.

So I took out this line:
   
And put in:


And I just get a JSP with a stack trace.  Although TermsAcceptanceException
extends DAOException, it doesn't go to error.jsp.

Two questions... what is the 'key' attribute of  used for, and
can anyone tell what I'm doing wrong?

Thanks!
--
Wendy Smoak


-
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]



Help with Exception handling

2004-11-17 Thread Wendy Smoak
I know I've tried this before, but so far I haven't gotten all the pieces
properly arranged so it works. :/

I currently have code like this in an Action:
try {
   benId = loginDAO.getBenId( asurite );
} catch ( TermsAcceptanceException ex ) {
   return mapping.findForward( "terms" );
}

In struts-config.xml:
 
   
   


It's my impression that I don't need to catch the exception, that I *should*
be able to let Action.execute(...) throw it and the framework can be
configured to deal appropriately with it.

So I took out this line:
   
And put in:


And I just get a JSP with a stack trace.  Although TermsAcceptanceException
extends DAOException, it doesn't go to error.jsp.

Two questions... what is the 'key' attribute of  used for, and
can anyone tell what I'm doing wrong?

Thanks!
-- 
Wendy Smoak


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