tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tim Funk <>
Subject Re: Replacement 401 pages
Date Wed, 04 Sep 2002 10:47:48 GMT
See section 9.8 of the spec:
A web application may specify that when errors occur, other resources in 
the application are used. These resources are specified in the 
deployment descriptor. If the location of the error handler is a servlet 
or a JSP, the following request attributes can be set:
- javax.servlet.error.status_code
- javax.servlet.error.exception_type
- javax.servlet.error.message
- javax.servlet.error.exception
- javax.servlet.error.request_uri

In your JSP or servlet, use request.getAttribute("...") for any of the 
above to get more details about the error. Then you can forward() or 
"whatever" based on your business logic.

Ben Walding wrote:
> Greetings all,
> Maybe someone can answer the following conundrum for me!
> I've replaced my 401 page with a servlet reference using the error-page 
> section of the web.xml. I'd like the servlet to display different 
> content based on what was accessed. At present I have to use javascript 
> (document.location.href) to do this at the client end.   Surely there is 
> a better way!?!
> The servlet "works" and forces authentication (once I'd added a Realm 
> header and 401 status code), however I can't detect the cause of the 
> authentication in the authentication page servlet ("I" know what 
> resource caused the authentication page to be called, but the servlet 
> doesn't seem to have any simple way to determine this). All I need is a 
> header being passed in on the request object, but if there is a spec 
> defined way to do this... I'm all ears...
> Since it isn't using a redirect (just some internal shenanigan), there 
> doesn't seem to be any headers to help me out.
> Cheers,
> Ben

To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

View raw message