Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Java > Java Open Source > Apache Tomcat
|
Apache Tomcat General discussion of the Apache Tomcat servlet container. For discussions specific to the Professional Apache Tomcat book, please see the book discussion forum for that book.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Apache Tomcat section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 27th, 2007, 07:31 AM
Registered User
 
Join Date: Dec 2007
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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.
 
Old January 2nd, 2008, 10:36 AM
Friend of Wrox
 
Join Date: Mar 2007
Posts: 373
Thanks: 0
Thanked 1 Time in 1 Post
Default

The mentioned <error-page> tag should work, all the error codes should be mentioned in order; like first error-page tag for 400, then 401, and 403, etc.


- Rakesh
 
Old January 8th, 2008, 05:30 AM
Registered User
 
Join Date: Dec 2007
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Rakesh,

  It is not working for 401 errors even if i provied all error codes in an order.

  Could you send me a snap of code ,how it is working.My developement box tomcat version is 5.5.23 and browser is IE.

  Thanks for your help advancly.

~Naga~,
Cisco Systems,
India.
 
Old February 9th, 2008, 01:54 PM
Authorized User
 
Join Date: Apr 2005
Posts: 71
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hello,

I think when the Authentication is failing, you must be seeing some other error code. 401 is a custom error page which requests for authentication. When the authentication fails, it should throw up 403, I think. So 403 custom error page is not working for you. Is this whats happenening?

-eNJay





Similar Threads
Thread Thread Starter Forum Replies Last Post
Custom Errors tectrix BOOK: ASP.NET Website Programming Problem-Design-Solution 1 October 6th, 2007 01:55 AM
CH9 - Apache not using custom error page d2nash BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0 3 June 20th, 2006 11:25 AM
Error from provide on apps. that runs OK on local hchlebowski ASP.NET 1.0 and 1.1 Basics 1 November 18th, 2005 06:50 PM
Unexplained 401 errors sejhemming VS.NET 2002/2003 0 April 20th, 2005 07:44 AM
custom error page texasraven Classic ASP Basics 0 May 13th, 2004 04:47 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.