tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tim Funk <funk...@joedog.org>
Subject Re: HttpServletResponse.setContentLength() method in Tomcat 5.5.9
Date Thu, 15 Sep 2005 18:24:00 GMT
This is expected behavior and there are bug reports (closed as INVALID) 
against this issue.

The 2.5 servlet spec clarifies the use of setContentLength() and allows more 
headers to be set even if setContentLength(0) is called.

-Tim

Ahab Abouzour wrote:

> Hello all,
> 
> My servlet stopped working when I moved from
> Tomcat4.0.6 to Tomcat5.5.9. After investigating the
> problem, it turns out that if the
> HttpServletResponse.setContentLength() method is
> called, subsequent calls (e.g. setHeader(),
> addHeader(),addCookie()..etc) into the
> HttpServletResponse object are completely ignored (or
> discarded  from underneath!). 
> 
> For example, if I do the following in my service
> method: (httpResponse is defined HttpServletResponse)
> 
> httpResopnse.setStatus(204); // I tried 200 and got
> the same problem, I guess status code doesn't play
> part in this problem.
> httpResponse.setHeader("header1","value1"); //works
> httpResponse.setHeader("header2","value2"); //works
> httpResponse.setContentLength(0); // nothing gets set 
> on the response object after this point
> httpResponse.setHeader("header3","value3"); //
> ignored!
> httpResponse.addCookie(new
> Cookie("JSESSIONID","myCookie")); // ignored!
> 
> My proxy shows that header1 and header2 are set
> correctly but header3 and my cookie are missing! It
> seems that it expects setContentLength is the last
> method to be set on the response object and any method
> call after that on the resopnse object gets ignored
> (or discarded)
> 
> I have attached a simple servlet that reproduces this
> problem.
> 
> My question: is this an expected behaviour? I checked
> the http specs and the servlet 2.4 specs but nothing
> specified this behaviour. Can someone please explain
> if this is the expected behaviour (and why?
> specs..etc) or it's a bug?
> 
> Thanks in advance,

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


Mime
View raw message