> I'm assuming that getParameter() looks in the body of the
> request on a POST in order to find the values.
Yes.
> To do this
> it implicitly calls ServletRequest.getInputStream() or
> getReader().
getInputStream() I believe.
> Both of those methods say that they must throw
> IllegalStateException if the other method was previously
> called. They do not describe the behavior if the same
> method is called subsequently.
No problem if you call getXXX() multiple times.
> I assume that one of the reasons for the described behavior
> is so that the engine does not have to buffer the body of
> the request. That is the behavior I would wish for.
It's an error to call both because then you're half treating it as
binary, and half as text. Almost always it's one or the other. The
outside cases aren't worth suffering with the buffering problems.
> Now, say I have one servlet that based on the value of a
> parameter decides to forward the request to another servlet.
> Is the second servlet allowed to call getInputStream() or
> getReader()?
I believe the second servlet can call whatever wasn't previously
called.
> Logically I then presume that if the first servlet calls
> getParameter() on a POST and then forwards the request to
> another servlet, that a call to getParameter() on the 2nd
> servlet will/may also throw IllegalStateException. Is this
> the case?
Calling getParameter() in both the original and forwarded servlet is
fine, and won't throw an ISE. The first getParameter() call on a POST
will suck in the POST data and store it. It'll be available for all
later servlets.
> I believe that spec for getInputStream() and getReader()
> should be modified to say that they will throw
> IllegalStateException if they were previously called or if
> getParameter() was previously called for a POST.
If you call getParameter() and then getInputStream() it's not cause for
an exception. You'll just get an InputStream that returns -1 on each
read because the data will have already been read. It's possible
calling getParameter() on a POST after having already called getReader()
will throw -- and vice versa, and maybe if so it should be documented,
but mixing a POST getParameter() with a getReader() does seem fairly
ridiculous. What would you be trying to read?
-jh-
--
Jason Hunter
[EMAIL PROTECTED]
Book: http://www.servlets.com/book
Article: http://www.javaworld.com/jw-12-1998/jw-12-servletapi.html
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html