You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Prashant Kadam <pr...@gmail.com> on 2014/03/06 10:25:06 UTC
setting org.apache.coyote.Response.isCommitted variable
I am including one jsp in another jsp, there are different behaviors for 2
tomcat versions as below
1. case in 7.0.37 - setCommitted(true) was called and thus in tiles code
(pasted below), it includes the jsp and works fine
public class TilesRequestProcessor extends RequestProcessor
protected void doForward( String uri, HttpServletRequest
request, HttpServletResponse response) throws IOException,
ServletException {
if (response.isCommitted()) {
this.doInclude(uri, request, response);
} else {
super.doForward(uri, request, response); }
}
2. case in 7.0.39 - setCommitted() was not being called and thus
isCommitted - default is false, and in this case it tries to forward and
thus call super.doForward(uri, request, response) as per above code. Now as
response is already committed but due to this flag value being false, it
tries to flush again giving issue of flushing of already flushed response.
and thus giving IOException: Stream closed issue.
so the problem is, if response is already committed why
org.apache.coyote.Response.isCommitted not being set to true ?
Thanks
Prashant Kadam
--
~ Prashant Kadam
Re: setting org.apache.coyote.Response.isCommitted variable
Posted by Konstantin Kolinko <kn...@gmail.com>.
2014-03-06 13:25 GMT+04:00 Prashant Kadam <pr...@gmail.com>:
> I am including one jsp in another jsp, there are different behaviors for 2
> tomcat versions as below
>
> 1. case in 7.0.37 - setCommitted(true) was called and thus in tiles code
> (pasted below), it includes the jsp and works fine
>
> public class TilesRequestProcessor extends RequestProcessor
> protected void doForward( String uri, HttpServletRequest
> request, HttpServletResponse response) throws IOException,
> ServletException {
> if (response.isCommitted()) {
> this.doInclude(uri, request, response);
> } else {
> super.doForward(uri, request, response); }
> }
>
> 2. case in 7.0.39 - setCommitted() was not being called and thus
> isCommitted - default is false, and in this case it tries to forward and
> thus call super.doForward(uri, request, response) as per above code. Now as
> response is already committed but due to this flag value being false, it
> tries to flush again giving issue of flushing of already flushed response.
> and thus giving IOException: Stream closed issue.
> so the problem is, if response is already committed why
> org.apache.coyote.Response.isCommitted not being set to true ?
>
1. "setCommitted() was not being called"
The code that called setCommitted() in 7.0.37, is it still being called?
Where it starts to differ between versions?
2. Request/Response may be wrapped (e.g. in a Filter).
Methods called on a wrapped class may be intercepted and not passed to
Tomcat code.
There was this change in 7.0.39:
http://svn.apache.org/r1459087
"Ensure HEAD requests return the correct content length when the
requested resource uses a Writer."
It add a flush() call, but that should not matter as the output is not
printed anywhere (just its length is calculated).
3. Flushing of a flushed stream is OK, as many times as you wish.
Flushing of a closed stream is not OK and is expected to give an IOException.
Why the stream is closed?
4. Can you simplify your code to make a test case / reproducer webapp out of it?
Best regards,
Konstantin Kolinko
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org