https://bz.apache.org/bugzilla/show_bug.cgi?id=62471
Bug ID: 62471
Summary: Cannot set status code if Servlet is used as error
page
Product: Tomcat 9
Version: 9.0.6
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P2
Component: Catalina
Assignee: [email protected]
Reporter: [email protected]
Target Milestone: -----
This bug happens with Tomcat 9.0.6 and later.
9.0.5 and earlier (including the 8.5 releases) are NOT affected.
Assume the following in web.xml:
<error-page>
<error-code>404</error-code>
<location>/errorRedirect</location>
</error-page>
<servlet>
<servlet-name>Error Redirect Servlet</servlet-name>
<servlet-class>org.duckdns.owly.tomcat9test.ErrorRedirectServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Error Redirect Servlet</servlet-name>
<url-pattern>/errorRedirect</url-pattern>
</servlet-mapping>
Tomcat 9.0.6 and later will always return a Response with status 404 if a non
existing page is accessed - no matter what I do in
ErrorRedirectServlet.doGet(Request, Response).
This is especially bad if one wants to send a redirect, as the location header
is set, yet due to the status code not being 302 it is ignored by the browser.
I tested response.sendRedirect("error.html"), both with and without a preceding
response.setStauts(302).
A small sample project is available at
https://github.com/j-be/tomcat-9-redirect-test.
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]