You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Duane Morse <dm...@eldocomp.com> on 2000/11/30 22:13:31 UTC

Tomcat 3.2 tries to read POST data before forwarding to JSP

The following partial stack trace illustrates a problem/bug in Tomcat 3.2
(final release) when a servlet processes
a POST request and then forwards processing to a JSP.   In "pre-processing",
Tomcat is trying to read the form
data, but since it's already been read, it generates a "short read" error.
Since the servlet API
specifically says that the forward command allows one servlet to do some
processing of a message before
passing on the work to another servlet, this behavior is either a bug in the
Tomcat 3.2 implementation (trying
to read the POST data without knowing whether the subsequent servlet wants
the data) or it's a serious shortcoming
of the servlet API (you can't ever forward a POST request).

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:691) 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:326) at
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:370) at
javax.servlet.http.HttpServlet.service(HttpServlet.java:853) at
org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:404) at
org.apache.tomcat.core.Handler.service(Handler.java:286) at
org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372) at
org.apache.tomcat.facade.RequestDispatcherImpl.forward(RequestDispatcherImpl
.java:194) 


Duane Morse, Eldorado Computing Inc., Phoenix Arizona


Re: Tomcat 3.2 tries to read POST data before forwarding to JSP

Posted by Matt Goss <mg...@rtci.com>.
thanks... :)
Matt

"Craig R. McClanahan" wrote:

> Matt Goss wrote:
>
> > Craig,
> > I'm looking at using the MVC method for a current project... how exactly does
> > struts benifit this framework?
>
> Struts is an implementation of the MVC processing model, including a controller
> servlet and a framework for defining actions, plus mechanisms for assigning logical
> names to business and presentation logic components so that changes in the path of a
> JSP page (for example) do not require changes to the application logic in your
> actions.  There's also a very nice custom tag library for building internationalized
> form-based web applications.
>
> For more info, see <http://jakarta.apache.org/struts>, and join the STRUTS-USER
> maililng list.
>
> >
> > just curious...
> > Also (since, I've got you ear), I've tried a similar process under tomcat 3.1
> > where I route all requests (ie<servlet-mapping><servlet-name>router</servlet-name>
> > <url-pattern>/*</url-pattern></servlet-mapping>)through a router servlet to check
> > login and whatnot. I couldn't get it to work... is this a bug in 3.1??? We are
> > upgrading to 3.2 now that it is released and I was hoping that would fix the
> > problem...
>
> If you map to "/*", your controller servlet will indeed catch all requests.  The
> problem is that you won't be able to forward to a JSP page later -- because the "/*"
> pattern will catch JSP pages also :-(.
>
> What I like to do is map the controller servlet to an extension (my favorite is "*.do"
> which implies "go do something").  Then, I can have a form submit that goes to a url
> like:
>
>     /myapp/saveCustomer.do
>
> which will be sent to the controller servlet, which then figures out which action to
> call based on the "/saveCustomer" part (which your servlet can extract by calling
> getServletPath() and doing a little string processing), and things go on from there.
>
> >
> > thanks,
> > Matt Goss
> >
>
> Craig
>
> >
> > "Craig R. McClanahan" wrote:
> >
> > > Duane,
> > >
> > > The problem you're referring to doesn't happen to me, even though I use this
> > > kind of programming approach all the time (in Struts).  Do you have a simple
> > > test case that you can send to help us isolate this?
> > >
> > > Craig McClanahan

Re: Tomcat 3.2 tries to read POST data before forwarding to JSP

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

> Craig,
> I'm looking at using the MVC method for a current project... how exactly does
> struts benifit this framework?

Struts is an implementation of the MVC processing model, including a controller
servlet and a framework for defining actions, plus mechanisms for assigning logical
names to business and presentation logic components so that changes in the path of a
JSP page (for example) do not require changes to the application logic in your
actions.  There's also a very nice custom tag library for building internationalized
form-based web applications.

For more info, see <http://jakarta.apache.org/struts>, and join the STRUTS-USER
maililng list.

>
> just curious...
> Also (since, I've got you ear), I've tried a similar process under tomcat 3.1
> where I route all requests (ie<servlet-mapping><servlet-name>router</servlet-name>
> <url-pattern>/*</url-pattern></servlet-mapping>)through a router servlet to check
> login and whatnot. I couldn't get it to work... is this a bug in 3.1??? We are
> upgrading to 3.2 now that it is released and I was hoping that would fix the
> problem...

If you map to "/*", your controller servlet will indeed catch all requests.  The
problem is that you won't be able to forward to a JSP page later -- because the "/*"
pattern will catch JSP pages also :-(.

What I like to do is map the controller servlet to an extension (my favorite is "*.do"
which implies "go do something").  Then, I can have a form submit that goes to a url
like:

    /myapp/saveCustomer.do

which will be sent to the controller servlet, which then figures out which action to
call based on the "/saveCustomer" part (which your servlet can extract by calling
getServletPath() and doing a little string processing), and things go on from there.

>
> thanks,
> Matt Goss
>

Craig


>
> "Craig R. McClanahan" wrote:
>
> > Duane,
> >
> > The problem you're referring to doesn't happen to me, even though I use this
> > kind of programming approach all the time (in Struts).  Do you have a simple
> > test case that you can send to help us isolate this?
> >
> > Craig McClanahan


Re: Tomcat 3.2 tries to read POST data before forwarding to JSP

Posted by Matt Goss <mg...@rtci.com>.
Craig,
I'm looking at using the MVC method for a current project... how exactly does
struts benifit this framework?
just curious...
Also (since, I've got you ear), I've tried a similar process under tomcat 3.1
where I route all requests (ie<servlet-mapping><servlet-name>router</servlet-name>
<url-pattern>/*</url-pattern></servlet-mapping>)through a router servlet to check
login and whatnot. I couldn't get it to work... is this a bug in 3.1??? We are
upgrading to 3.2 now that it is released and I was hoping that would fix the
problem...
thanks,
Matt Goss

"Craig R. McClanahan" wrote:

> Duane,
>
> The problem you're referring to doesn't happen to me, even though I use this
> kind of programming approach all the time (in Struts).  Do you have a simple
> test case that you can send to help us isolate this?
>
> Craig McClanahan

Re: Tomcat 3.2 tries to read POST data before forwarding to JSP

Posted by "Craig R. McClanahan" <Cr...@eng.sun.com>.
Duane,

The problem you're referring to doesn't happen to me, even though I use this
kind of programming approach all the time (in Struts).  Do you have a simple
test case that you can send to help us isolate this?

Craig McClanahan


Duane Morse wrote:

> The following partial stack trace illustrates a problem/bug in Tomcat 3.2
> (final release) when a servlet processes
> a POST request and then forwards processing to a JSP.   In "pre-processing",
> Tomcat is trying to read the form
> data, but since it's already been read, it generates a "short read" error.
> Since the servlet API
> specifically says that the forward command allows one servlet to do some
> processing of a message before
> passing on the work to another servlet, this behavior is either a bug in the
> Tomcat 3.2 implementation (trying
> to read the POST data without knowing whether the subsequent servlet wants
> the data) or it's a serious shortcoming
> of the servlet API (you can't ever forward a POST request).
>
> 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:691) 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:326) at
> org.apache.jasper.servlet.JspServlet.service(JspServlet.java:370) at
> javax.servlet.http.HttpServlet.service(HttpServlet.java:853) at
> org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:404) at
> org.apache.tomcat.core.Handler.service(Handler.java:286) at
> org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372) at
> org.apache.tomcat.facade.RequestDispatcherImpl.forward(RequestDispatcherImpl
> .java:194)
>
> Duane Morse, Eldorado Computing Inc., Phoenix Arizona