tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From peter lin <peter....@labs.gte.com>
Subject Re: tricky question
Date Thu, 17 Oct 2002 18:33:16 GMT

yup, that really worked :)

surprising isn't it 

peter

Kris Schneider wrote:
> 
> Peter,
> 
> If you're hitting an error page resource due to an exception, the request
> attribute "javax.servlet.error.exception" is required to contain the associated
> Throwable object. If you're hitting an error page resource due to a status
> code, the request attribute "javax.servlet.error.status_code" is required to
> contain the associated Integer object. So, if your error page resource is a
> JSP, you can get (and log) the Throwable with:
> 
> <%
> Throwable t = (Throwable)request.getAttribute("javax.servlet.error.exception");
> application.log("Some msg", t);
> %>
> 
> The log file name and location are app server specific. Did
> pageContext.findAttribute("Throwable") really work, or was that a typo?
> 
> Quoting peter lin <peter.lin@labs.gte.com>:
> 
> >
> > Awesome!  thanks for the tip remy.  that did it.  for those who need to
> > do the same thing, in your custom error jsp, add the following code to
> > log the exception.
> >
> > <%
> > Throwable tw = (Throwable)pageContext.findAttribute("Throwable");
> > if (tw != null ) {
> >   exception = tw;
> > }
> > try {
> >   exception.printStackTrace(new java.io.PrintWriter(out));
> > }catch (Exception e) {
> >   out.println("no exception");
> > }
> > %>
> >
> > peter
> >
> >
> >
> > Remy Maucherat wrote:
> > >
> > > peter lin wrote:
> > >
> > > > I'm hoping others have done this, since I can't think of a way.
> > > >
> > > > I modified my web.xml to redirect nullpointerexception and jspexception
> > > > to my own error page, but I still want to log the exception to the
> > > > localhost_log. I made test pages to purposely cause nullpointer and jsp
> > > > exceptions. so far it's good. When the request gets logged in access
> > log
> > > > the status code is 200. No log in localhost_log appears.
> > > >
> > > > I don't see any way in the request/response API to get the stacktrace.
> > > >
> > > > Is this even possible?
> > >
> > > You can get the Throwable from the atribute, and then use
> > > Throwable.printStackTrace(PrintStream).
> > > I think that's what you want, right ?
> > >
> > > Remy
> > >
> > > --
> > > To unsubscribe, e-mail:
> > <mailto:tomcat-user-unsubscribe@jakarta.apache.org>
> > > For additional commands, e-mail:
> > <mailto:tomcat-user-help@jakarta.apache.org>
> >
> > --
> > To unsubscribe, e-mail:
> > <mailto:tomcat-user-unsubscribe@jakarta.apache.org>
> > For additional commands, e-mail:
> > <mailto:tomcat-user-help@jakarta.apache.org>
> >
> >
> 
> --
> Kris Schneider <mailto:kris@dotech.com>
> D.O.Tech       <http://www.dotech.com/>
> 
> --
> To unsubscribe, e-mail:   <mailto:tomcat-user-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail: <mailto:tomcat-user-help@jakarta.apache.org>

--
To unsubscribe, e-mail:   <mailto:tomcat-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:tomcat-user-help@jakarta.apache.org>


Mime
View raw message