Typically information to be displayed by the JSP is communicated via the
ServletRequest.setAttribute and the RequestDispatcher.  For example,
ServletA performs the business logic and stores the results using
setAttribute(java.lang.String name, java.lang.Object o), and the servlet or
jsp retreives the information using getAttribute(java.lang.String name).

If your servlet performing the business logic already called
ServletResponse.getOutputStream() or ServletResponse.getWriter() before
calling RequestDispatcher.forward then that might explain the behavior your
experiencing with Tomcat (it's not allowed by the Servlet Spec).


-----Original Message-----
From: Duane Morse [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, November 29, 2000 3:27 PM
To: [EMAIL PROTECTED]
Subject: How does one forward a POST request when the POST data has
alread y been processed?


I ran into a problem with the Tomcat 3.2-b8 release, and it has implications
beyond the Tomcat
implementation; hence my posting here.

I have a servlet which processes a form which uses the POST method, and it
forwards the request
to another servlet (in this case,  a JSP) after adding a data structure to
the request object which
the target servlet should use to format the response page.  This is your
classic "let JSP handle
the presentation" mode of operations.  Since the real response data is in my
own data object,
the target servlet ignores the original input.  Tomcat's problem with this
is that it apparently tries to
prepare the target for processing POST data, but the data has already been
read, so it gets a
"short data" error (i.e., CONTENT_LENGTH is n, but the number of data bytes
in the stream is 0).

I can't see any way of changing the method type or the content length in the
request object before
forwarding it.  How should I invoke a servlet in a manner that doesn't
potentially confuse the servlet container?

Duane Morse, Eldorado Computing Inc., Phoenix AZ

___________________________________________________________________________
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

___________________________________________________________________________
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

Reply via email to