On 28/04/18 07:26, Shinsuke Sugaya wrote:
> Hi,
> 
> Tomcat 9.0.7 does not seem to be able to update a status code in an
> error page(JSP).
> But it works on Tomcat 8.5 and 9.0.5.
> 
> Steps to reproduce:
> 1. Set JSP path to <error-page> in web.xml
>  ex. 
> https://github.com/codelibs/fess/blob/fess-12.1.2/src/main/webapp/WEB-INF/web.xml#L148
> 2. Redirect in JSP page
>  ex. 
> https://github.com/codelibs/fess/blob/fess-12.1.2/src/main/webapp/WEB-INF/view/error/redirect.jsp#L24
> 3. Access to a non-existent page(404 access)
>  $ curl -I localhost:8080/aaa
>  HTTP/1.1 404
>  Set-Cookie: JSESSIONID=0AE0A09F8CAF0A60AB169B24C660A993; Path=/; HttpOnly
>  Location: /error/notfound/?url=%2Faaa
>  Content-Type: text/html;charset=UTF-8
>  Transfer-Encoding: chunked
>  Date: Sat, 28 Apr 2018 05:47:16 GMT
> 
> In Step 3, Tomcat 8.5 and 9.0.5 prints "HTTP/1.1 302".
> 
> I think that the cause is the following fix:
> http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/Response.java?r1=1823565&r2=1823564&pathrev=1823565
> 
> Could you check if this behavior is correct in Tomcat 9.0.7?

It is not. There used to be a requirement that error pages could not set
the status code. That was explicitly removed in Servlet 2.4.

However, change in question was made for a good reason. When something
goes wrong, there are often multiple calls to setStatus() with the first
one setting the correct status code and subsequent calls over-writing it
with a more general code. The aim was to keep the first, more specific,
code.

I need to go back and take another look at this to see if I can find a
better solution. I'll keep your use case in mind while I do that.

Mark

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

Reply via email to