aspose file tools*
The moose likes Struts and the fly likes logging JSP exceptions Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "logging JSP exceptions" Watch "logging JSP exceptions" New topic
Author

logging JSP exceptions

Daniel Dalton
Ranch Hand

Joined: Mar 20, 2005
Posts: 146
How can I log exceptions thrown by my JSP pages? I want to catch and log ALL errors (whether thrown by Action classes, business objects or JSPs...).

If I understand the process correctly, I should be able to extend the Struts ExceptionHandler and use something like log4j to log exceptions. The problem I have is that JSP errors don't seem to be being directed to my new Global Exception Handler, which I've configured in struts-config.xml

Currently when a JSP generated exception crops up, the application displays a blank screen because the response is already committed, so the forward to my error.jsp fails too!

I can get the exceptions from the server logs, but I also want them to be logged to my application log, so that everything is centralised. Am I missing the point? Am I not supposed to want to log JSP errors?

For instance, I know what caused the following, and can fix it, but how do I get a handle on it to log it!

Thanks for any assistance:


Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
Please show us:

1- The global-excpetion entry in your struts-config.xml file
2- The code in your exception handler.

If you want to keep the original function of the exception handler, you must end your overridden execute method with:

return super.execute(....);
[ August 31, 2006: Message edited by: Merrill Higginson ]

Merrill
Consultant, Sima Solutions
Daniel Dalton
Ranch Hand

Joined: Mar 20, 2005
Posts: 146
No problem:



and:

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: logging JSP exceptions