Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Java > Java Open Source > Apache Tomcat
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old December 27th, 2007, 07:31 AM
Registered User
 
Join Date: Dec 2007
Location: chennai, TamilNadu, India.
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.
Reply With Quote
  #2 (permalink)  
Old January 2nd, 2008, 10:36 AM
Friend of Wrox
 
Join Date: Mar 2007
Location: Hyderabad, A.P., India.
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
Reply With Quote
  #3 (permalink)  
Old January 8th, 2008, 05:30 AM
Registered User
 
Join Date: Dec 2007
Location: chennai, TamilNadu, India.
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.
Reply With Quote
  #4 (permalink)  
Old February 9th, 2008, 01:54 PM
Authorized User
 
Join Date: Apr 2005
Location: , , India.
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
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 11:20 PM.


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