Bug 31794 - Custom HTTP 400 error page
Summary: Custom HTTP 400 error page
Status: RESOLVED INVALID
Alias: None
Product: Tomcat 5
Classification: Unclassified
Component: Unknown (show other bugs)
Version: 5.0.30
Hardware: PC other
: P3 normal (vote)
Target Milestone: ---
Assignee: Tomcat Developers Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-10-20 07:27 UTC by PG
Modified: 2005-06-01 16:19 UTC (History)
2 users (show)



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description PG 2004-10-20 07:27:14 UTC
Hi

I have a custom HTTP 400 page and I have configured web.xml as follows:

<error-page>
	<error-code>400</error-code>
  	<location>/400.jsp</location>
</error-page>
<error-page>
	<exception-type>java.lang.Throwable</exception-type>
	<location>/error.jsp</location>
</error-page>
<error-page>
	<exception-type>java.io.FileNotFoundException</exception-type>
	<location>/404.jsp</location>
</error-page>
<error-page>
        <error-code>403</error-code>
  	<location>/403.jsp</location>
</error-page>
<error-page>
	<error-code>404</error-code>
	<location>/404.jsp</location>
</error-page>		

Now, when I pass in a bad request to my webapp [Example: http://pg1:88/epass/members/login/_ps_login_p1/normal/_pm_login_p1/view/_st_login_p1/normal/_pid/login_p1/%%%%%%/view.]I expected to see my custom 400 error page.

But, Tomcat returns the standard HTTP 400 error page. I searched bugzilla but I couldn't find anything related to tihs. Is this a known bug?
Comment 1 Yoav Shapira 2004-10-22 17:19:27 UTC
Not only is it not a known bug, but custom 404 error mapping works for me (on 
5.0.28).  Please discuss on the mailing list if you want help for your specific 
setup.
Comment 2 quartz 2005-05-05 01:24:19 UTC
using 5.0.27, it still has the bug.
The Coyote http11 adapter catches the bad uri syntax and doesn't redirect to the
error page.

Example url: http://host/hoho%

<error-page>
<error-code>400</error-code>
<location>/WEB-INF/pages/servletErrors.jsp</location>
</error-page>
Comment 3 Yoav Shapira 2005-06-01 04:16:20 UTC
Please try 5.0.28 (latest stable on 5.0.x branch), 5.5.9 (latest stable
overall), or 5.0.30 beta (latest 5.0.x).  
Comment 4 quartz 2005-06-01 21:50:05 UTC
Not fixed in 5.0.30 either (assuming implicitely 5.0.28)

5.5.x doesn't matter, this bug must be fixed on 5.0.x stream anyway.
5.5.x requires updates and jdk15 which is not expected for a bug fix release.
Comment 5 Remy Maucherat 2005-06-01 22:56:17 UTC
5.5.x *does not* requires Java 5. It is very unlikely at this point there will
be another 5.0.x release.

Note: In case of a bad URI, or any invalid request (ex: no host), the connector
itself will return the 400. This will NOT be handled by the servlet layer, since
the request will never get mapped.

Please do not reopen the report.
Comment 6 quartz 2005-06-02 00:03:59 UTC
(Sorry Yoavs for CC'ing, I have to contradict the verdict and hope someone else
than our hurried friend will handle this...)

The 400 status code can have and should forward to a page handler if any.
It sure has no mapping, but doesn't need so. The url is in the web.xml plain simply.

I have seen the code for myself, and even if it is not easy to refactor the
oversight, this is the spec. The argument given is one from an implementation
perspective and has no weight given the spec wasn't respected. The limitation of
tomcat must be fixed.

I'm about to try this 5.5.x without 1.5... Last time, I checked, it wasn't working.
Comment 7 Remy Maucherat 2005-06-02 00:19:17 UTC
Please don't waste your time reopening the report. An invalid HTTP request
cannot be mapped, and thus cannot be processed according to the Servlet
specification.