You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Francis Galiegue <fg...@gmail.com> on 2006/04/25 12:02:27 UTC

Tomcat 5.0 : how to "redirect" a 401 error to a specific page

Hello,

Our webapp runs with Tomcat 5, Apache 2.0.46 from RHEL3, Tomcat 5.0.27
from JPackage, and communicate via mod_jk 1.2.6.

Here's the problem we face: our webapp sends notifications by email,
with a link to a JSP requiring a classical HTTP authentication dialog.
This same page is used for the login form into the application, and
its behaviour is controlled by the parameters passed to it.

When the user DOES NOT submit any information (ie, it presses "Cancel"
on the dialog box), Tomcat shows its 401 page. I've tried the
following:

* add an ErrorDocument directive to Apache config: no go;
* add an <error-page> tag with <error-code> and <location> into the
<web-app> section of WEB-INF/web.xml with the location pointing back
to the same page, with no parameters: no go either... It's even worse
in this case, since the Tomcat 401 page shows directly, the HTTP auth
dialog doesn't even appear.

I haven't tried _both_ at the same time, but I believe it wouldn't be
the solution.

As I'm not really fluent with Apache/Tomcat and webapps, I don't know
where I should look at to solve the problem. Any hints would be more
than welcome!

Thanks for reading, and it'd be nice to reply-all, since the two CC
are not on the list,
--
Francis Galiegue, fgaliegue@gmail.com, fg@one2team.com, fg6@wanadoo.fr
One2team - 12bis rue de la Pierre Levée, 75011 Paris - 0143381980
"When it comes to performance, weight is everything" - Tiff Needell

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Tomcat 5.0 : how to "redirect" a 401 error to a specific page

Posted by David Delbecq <de...@oma.be>.
See section 10.4.2 of http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html

You have to understand the page user see when he hit cancel has been
send by tomcat before the user hit cancel. This is the page which is
shown to user to indicate him he requires authentification. If you want
to customize the layout of this page, use the <error-page> <error-code>
<location> way, but do not, in you page send any redirect as it will
break authentification mecanism (the browser won't get it's 401 header
and thus won't show the http auth dialog to user).
Francis Galiegue a écrit :

>Hello,
>
>Our webapp runs with Tomcat 5, Apache 2.0.46 from RHEL3, Tomcat 5.0.27
>from JPackage, and communicate via mod_jk 1.2.6.
>
>Here's the problem we face: our webapp sends notifications by email,
>with a link to a JSP requiring a classical HTTP authentication dialog.
>This same page is used for the login form into the application, and
>its behaviour is controlled by the parameters passed to it.
>
>When the user DOES NOT submit any information (ie, it presses "Cancel"
>on the dialog box), Tomcat shows its 401 page. I've tried the
>following:
>
>* add an ErrorDocument directive to Apache config: no go;
>* add an <error-page> tag with <error-code> and <location> into the
><web-app> section of WEB-INF/web.xml with the location pointing back
>to the same page, with no parameters: no go either... It's even worse
>in this case, since the Tomcat 401 page shows directly, the HTTP auth
>dialog doesn't even appear.
>
>I haven't tried _both_ at the same time, but I believe it wouldn't be
>the solution.
>
>As I'm not really fluent with Apache/Tomcat and webapps, I don't know
>where I should look at to solve the problem. Any hints would be more
>than welcome!
>
>Thanks for reading, and it'd be nice to reply-all, since the two CC
>are not on the list,
>--
>Francis Galiegue, fgaliegue@gmail.com, fg@one2team.com, fg6@wanadoo.fr
>One2team - 12bis rue de la Pierre Levée, 75011 Paris - 0143381980
>"When it comes to performance, weight is everything" - Tiff Needell
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>For additional commands, e-mail: users-help@tomcat.apache.org
>
>  
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org