How to provide custom error page for 401 Errors
Hi,
I'm customizing error pages for HTTP error codes in Tomcat 5.5.23.Using <error-page> tag, tomcat is redirecting to the custom error pages for all errors except 401 errors. I'm using BASIC authentication method and browser is IE.If I use <error-page> tag in web.xml ,browser is not displaying authentication login dialog and it is showing standard 401 error page.If I remove the <error-page> element from the web.xml file everything works fine. I was hoping to use my own custom error page for 401 errors when a user of my application forgets his userId/password or clicks Cancel form the Authentication login dialog.
<error-page>
<error-code>401</error-code>
<location>/jsp/Error401.jsp</location>
</error-page>
Same like above configuration is working for all error codes.Some research helps me to place following code in the custom error page of 401 errors.
response.setStatus(HttpServletResponse.SC_UNAUTHOR IZED);
response.setHeader("WWW-Authenticate", "BASIC realm=\"WGL\"");
Now If I place <error-page> tag in web.xml ,browser is popping up authentication dialog.But when authentication fails it is redirecting to the standard error page instead of custom error page.
Thanks in advance for your help.
~Naga~,
Cisco Systems,
India.
|