You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Wyn Easton <wy...@yahoo.com> on 2000/11/14 12:24:06 UTC

Please Look - 3.2 beta 7 problem - RequestDispatcher include()

Are you not suppose to mix URL access with a RequestDispatcher?
Thanks.

Also, in 3.2 beta 6 I could do an include() then a forward().
Now in 3.2 beta 7 I get an illegalState error on the forward()
because of an open outputstream.  I'm not opening an output stream.
The include() must be doing it. 


--- Wyn Easton <wy...@yahoo.com> wrote:
> I'm having this problem on 3.2 beta 7
> 
> The exact text of the  exception is:
> 
> java.lang.IllegalArgumentException: Short Read
> 
> This Exception is being generated in HttpUtils.java in the
> parsePostData() method.
> 
> Here is what is happening:
> 
> I'm opening a HttpURLConnection to servlet_A that has been set to use
> the POST method by calling setRequestMethod("POST") for the
> HttpURLConnection. In servlet_A I get a ServletInputStream and
> read from the HttpURLConnection.
> I then get an ServletOutputStream from the response.
> I then get a RequestDispatcher for servlet_B.
> When I call the include() method I get the exception mentioned
> because parsePostData() in HttpUtils tries to read "len" number
> of bytes from the ServletInputStream "in" and there is nothing
> to read. I changed parsePostData() in HttpUtils to return an
> empty Hashtable for this case and it worked fine. 
> (Maybe this is how this should work since nothing read means no
> parameters in the POST data. Even if the len is greater than 0.)
> 
> However, if I try to use the ServletOutputStream after returning
> to servlet_A from servlet_B nothing is written to the original
> HttpURLConnection.  I don't know if the ServletOutputStream is
> being closed when I return from the include(). I don't get an
> Exception when writing to the ServletOutputStream. I just don't
> get any data at the listening end of the HttpURLConnection.
> 
> I'm going to modify my code to use the include() instead of
> the HttpURLConnection, but shouldn't it work either way?
> 
> Thanks.
> 
> 
> =====
> Wyn Easton
> wyn_easton@yahoo.com
> 
> __________________________________________________
> Do You Yahoo!?
> Yahoo! Calendar - Get organized for the holidays!
> http://calendar.yahoo.com/


=====
Wyn Easton
wyn_easton@yahoo.com

__________________________________________________
Do You Yahoo!?
Yahoo! Calendar - Get organized for the holidays!
http://calendar.yahoo.com/

Re: Please Look - 3.2 beta 7 problem - RequestDispatcher include()

Posted by "Craig R. McClanahan" <Cr...@eng.sun.com>.
Wyn Easton wrote:

> Are you not suppose to mix URL access with a RequestDispatcher?
> Thanks.
>
> Also, in 3.2 beta 6 I could do an include() then a forward().
> Now in 3.2 beta 7 I get an illegalState error on the forward()
> because of an open outputstream.  I'm not opening an output stream.
> The include() must be doing it.
>

This assumption is pretty close to being correct.

There was an absolutely horrible bug in 3.2 that caused all sorts of
problems with included servlets and JSP pages.  The "quick and dirty"
workaround was to have Tomcat 3.2b7 commit the response before processing
an include -- which is what causes the forward to fail now (since you
cannot do a forward after the response is committed).

Fixing this the right way this would require some fundamental changes to
3.2's architecture, which are unlikely given how late 3.2 already is.  As a
workaround, I would suggest that you change your application logic to
decide if you're going to do a forward *before* you actually do the
include.  (The include is wasted anyway, since any output it produces would
be thrown away.)

Craig McClanahan