You are viewing a plain text version of this content. The canonical link for it is here.
Posted to general@jakarta.apache.org by Kevin Jones <ke...@develop.com> on 2000/09/27 23:02:40 UTC

Forward inside a POST

I have a servlet with a doPost. The servlets eats all the data in the POST
request and then forwards to a JSP.

i) is this legal - my understanding is that I can't write to the client but
I can do anything I like with the incoming data

ii) if it is legal then why would Tomcat throw an exception?

I'm seeing a

java.lang.IllegalArgumentException: Short Read
        at javax.servlet.http.HttpUtils.parsePostData(HttpUtils.java:238)
        at
org.apache.tomcat.util.RequestUtil.readFormData(RequestUtil.java:101)
        at
org.apache.tomcat.core.RequestImpl.handleParameters(RequestImpl.java:681)
        at
org.apache.tomcat.core.RequestImpl.getParameterValues(RequestImpl.java:259)
        at
org.apache.tomcat.core.RequestImpl.getParameter(RequestImpl.java:250)
        at
org.apache.tomcat.facade.HttpServletRequestFacade.getParameter(HttpServletRe
questFacade.java:222)
        at
org.apache.jasper.servlet.JspServlet.preCompile(JspServlet.java:317)
        at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:361)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
        at
org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:387)
        at org.apache.tomcat.core.Handler.service(Handler.java:263)
        at
org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:371)
        at
org.apache.tomcat.facade.RequestDispatcherImpl.forward(RequestDispatcherImpl
.java:191)
        at com.develop.ewebjava.lab.SOAPAdd.doPost(SOAPAdd.java:40)

It's saying 'Short Read', so I assume that parsePostData is trying to read
the POST body based on the Content-Length header.

Help!!


Kevin Jones
DevelopMentor
www.develop.com


Re: Forward inside a POST

Posted by Harrison <hu...@web-services.net>.
We had a similar problem in an early version of a custom java web server we
developed. (Not Tomcat.)

A MS proxy server was sending less than the specified contact length for POST
replys, causing our early server code to hang waiting for the remainder.  We
ended up adding a simple timeout to let us get on with the processing.  This
sounds like what Tomcat may be doing.  What is the source of the POST that
causes the problem?  (All, some browsers, ...)

Harrison
www.Help-Wanted.Net -- Search millions of job postings


Kevin Jones wrote:

> I have a servlet with a doPost. The servlets eats all the data in the POST
> request and then forwards to a JSP.
>
> i) is this legal - my understanding is that I can't write to the client but
> I can do anything I like with the incoming data
>
> ii) if it is legal then why would Tomcat throw an exception?
>
> I'm seeing a
>
> java.lang.IllegalArgumentException: Short Read
>         at javax.servlet.http.HttpUtils.parsePostData(HttpUtils.java:238)
>         at
> org.apache.tomcat.util.RequestUtil.readFormData(RequestUtil.java:101)
>         at
> org.apache.tomcat.core.RequestImpl.handleParameters(RequestImpl.java:681)
>         at
> org.apache.tomcat.core.RequestImpl.getParameterValues(RequestImpl.java:259)
>         at
> org.apache.tomcat.core.RequestImpl.getParameter(RequestImpl.java:250)
>         at
> org.apache.tomcat.facade.HttpServletRequestFacade.getParameter(HttpServletRe
> questFacade.java:222)
>         at
> org.apache.jasper.servlet.JspServlet.preCompile(JspServlet.java:317)
>         at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:361)
>         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
>         at
> org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:387)
>         at org.apache.tomcat.core.Handler.service(Handler.java:263)
>         at
> org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:371)
>         at
> org.apache.tomcat.facade.RequestDispatcherImpl.forward(RequestDispatcherImpl
> .java:191)
>         at com.develop.ewebjava.lab.SOAPAdd.doPost(SOAPAdd.java:40)
>
> It's saying 'Short Read', so I assume that parsePostData is trying to read
> the POST body based on the Content-Length header.
>
> Help!!
>
> Kevin Jones
> DevelopMentor
> www.develop.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: general-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: general-help@jakarta.apache.org




RE: Forward inside a POST

Posted by Chris Hsu <cc...@uniscape.com>.
Hi;
I encountered the same problems on tomcat 3.1 and 3.2 beta 4.

I'm using type II architecture. My servlet processes the request and 
use RequestDispatcher.forward() to invoke a specific JSP page.

1. Inside the scope of the servlet, req.getInputStream() is called
because I'd like to process the form data myself.
2. After a specific page is determined, RequestDispatcher.forward()
is called.
3. From the stack, we can see that the JSP container is preparing 
parameters for the JSP page.
4. Data in GET part is first processed. Then data in POST is processed
in RequestImpl.handleParameters
5. Unfortunately, the input stream of Request is consumed fully by the 
servlet while it requires to read contentLength bytes. An exception is
thrown.

Based on this implementation, it virtually prohibits reading the POST
data if you do any forwarding. I made code changes in 
javax.servlet.http.HttpUtils.parsePostData() to return instead
of throwing an exception if input stream is consumed already.
I am not sure whether this is the right fix. But it works for me.

The reason I have to parse POST data myself is because the implementation
of the current tomcat is not internationalized. You can see that in the
source code comment. But this is another issue though.

Chris Hsu


-----Original Message-----
From: Kevin Jones [mailto:kevinj@develop.com]
Sent: Wednesday, September 27, 2000 2:03 PM
To: Tomcat-General
Subject: Forward inside a POST


I have a servlet with a doPost. The servlets eats all the data in the POST
request and then forwards to a JSP.

i) is this legal - my understanding is that I can't write to the client but
I can do anything I like with the incoming data

ii) if it is legal then why would Tomcat throw an exception?

I'm seeing a

java.lang.IllegalArgumentException: Short Read
        at javax.servlet.http.HttpUtils.parsePostData(HttpUtils.java:238)
        at
org.apache.tomcat.util.RequestUtil.readFormData(RequestUtil.java:101)
        at
org.apache.tomcat.core.RequestImpl.handleParameters(RequestImpl.java:681)
        at
org.apache.tomcat.core.RequestImpl.getParameterValues(RequestImpl.java:259)
        at
org.apache.tomcat.core.RequestImpl.getParameter(RequestImpl.java:250)
        at
org.apache.tomcat.facade.HttpServletRequestFacade.getParameter(HttpServletRe
questFacade.java:222)
        at
org.apache.jasper.servlet.JspServlet.preCompile(JspServlet.java:317)
        at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:361)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
        at
org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:387)
        at org.apache.tomcat.core.Handler.service(Handler.java:263)
        at
org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:371)
        at
org.apache.tomcat.facade.RequestDispatcherImpl.forward(RequestDispatcherImpl
.java:191)
        at com.develop.ewebjava.lab.SOAPAdd.doPost(SOAPAdd.java:40)

It's saying 'Short Read', so I assume that parsePostData is trying to read
the POST body based on the Content-Length header.

Help!!


Kevin Jones
DevelopMentor
www.develop.com


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