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

Reply via email to