Hi Chris, Thanks for this suggestion. Just to be sure I'm understanding correctly, the procedure would be
1. Add an error-page element to my xml doc that will be visited whenever an exception is generated from my JSP or servlet. 2. Configure valve to output a stack trace and the original request URI that generated the error. Is that right? Also is valve smart enough to understand that I don't want to see "500.jsp" in my log file but rather something like "search_results.jsp?category=1" ? Thanks again, - Dave Christopher Schultz-2 wrote: > > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > Dave, > > On 5/20/2010 5:30 PM, laredotornado wrote: >> Is there a way to configure Tomcat to record what the URL was in the >> browser >> when this error occurred? > > Do you have any <error-page> elements in your web.xml? Do you have > custom error pages? If you do, the best place to put this kind of stuff > is in your custom error pages - if they are either JSPs or some other > dynamic resource. > > See section 9.9 of the servlet spec, and you'll find that you can obtain > the original URL and other interesting information using request > attributes: > > javax.servlet.error.status_code > javax.servlet.error.exception_type > javax.servlet.error.message > javax.servlet.error.exception > javax.servlet.error.request_uri > javax.servlet.error.servlet_name > >> While I'm at it, is there a way to also link in >> all session and request data at the time of the error (since the request >> may >> have been submitted via HTTP POST)? > > The best thing for you to do is manually dump that information when an > error occurs. I suppose there's the possibility that you could set up an > AccessLogValve that only logs when an error occurs: > > <Valve className="org.apache.catalina.valves.AccessLogValve" > ... [file and path parameters] ... > condition="javax.servlet.error.request_uri" > pattern="[%t] %a %{javax.servlet.error.request_uri}r (no CRLF) > %{my.session.attribute}s (no CRLF here, either) > %{my.other.session.attribute}s" /> > > See the documentation for AccessLogValve to see what all those setting > mean. > > This can't dump the /entire/ session, but it can dump pre-defined > session attributes. It also can't dump the non-GET request parameters. > > If you want to look at ExtendedAccessLogValve, it can do some more > exciting things, though I think you have to know the parameter names > beforehand: it can't simply dump the entire set of request parameters. > > Hope that helps, > - -chris > -----BEGIN PGP SIGNATURE----- > Version: GnuPG v1.4.10 (MingW32) > Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ > > iEYEARECAAYFAkv1uOoACgkQ9CaO5/Lv0PD3UQCfS3J7W0kcs+UVKkl4+5nqIfCS > RcEAn0G+pD9BgeOIkITbZmz/0fJk9n4D > =shmH > -----END PGP SIGNATURE----- > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org > For additional commands, e-mail: users-h...@tomcat.apache.org > > > -- View this message in context: http://old.nabble.com/Way-to-record-what-URL-an-error-originated-from-in-my-localhost-file--tp28626297p28638705.html Sent from the Tomcat - User mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org