You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by bu...@apache.org on 2018/06/18 16:12:40 UTC

[Bug 62471] New: Cannot set status code if Servlet is used as error page

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: dev@tomcat.apache.org
          Reporter: juri.berlanda@tuwien.ac.at
  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: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[Bug 62471] Cannot set status code if Servlet is used as error page

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=62471

Mark Thomas <ma...@apache.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED

--- Comment #1 from Mark Thomas <ma...@apache.org> ---
Already fixed in trunk.

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org