my dog learned polymorphism*
The moose likes Servlets and the fly likes Unexpected Error Logging Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Unexpected Error Logging" Watch "Unexpected Error Logging" New topic
Author

Unexpected Error Logging

Ronnie Phelps
Ranch Hand

Joined: Mar 12, 2001
Posts: 329
Can someone point me in the right direction on where I would want to begin creating an error log for my jsp pages. I don't have a problem throwing and logging expected errors in JSP when they occur...I need to somehow log error messages that are unexpected.
Tony Alicea
Desperado
Sheriff

Joined: Jan 30, 2000
Posts: 3222
    
    5
If you set up a JSP called for example "myError.jsp" with this directive
<%@ page isErrorPage="true" %>
and then use <%@ page errorPage="myError.jsp" %>
in other pages, then any runtime exceptions in a JSP will cause "myError.jsp" to be executed. In this page you can do the logging.
I would <jsp:forward page="LoggingServlet"/> to a Servlet and do the logging there since I prefer not to have too much Java code in a JSP.


Tony Alicea
Senior Java Web Application Developer, SCPJ2, SCWCD
Ronnie Phelps
Ranch Hand

Joined: Mar 12, 2001
Posts: 329
I didn't know that this approach would apply to any runtime exception. Thanks Tony that was very helpful.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Unexpected Error Logging
 
Similar Threads
How do I declare a resource in my jboss-web.xml file?
RAD 7.0 logging error
log4j and apache.commons.logging
Apache GERONIMO log problem
Logging errors from jsp