Stef�n F. Stef�nsson wrote:
> Hello.
>
> Here's my problem:
>
> I have a servlet that initiates a bean. This bean is put in the request
> object as an attribute and then forwarded to a JSP page. That JSP has a
> form where the user selects one thing from a drop down list. Then (when
> he/she presses the submit button) it's directed to a servlet that uses
> the value of the selected item in the drop down list. The problem is
> that I have to have the bean as well. I don't want to put it in the
> session, I want to keep it in the request object but, of course, the
> bean disappears from the request object when the JSP is called.
>
Why not? That is exactly what the session is for.
Request attributes disappear as soon as the request is completed. In your case,
that happens when the JSP page output is returned to the browser. The next input
(the one that goes to your servlet) is a separate request.
>
> So my question is: Is there any way (on a JSP) to put a Java object
> into the request object that is sent to the web server? I've tried to
> add an attribute to the request object but that doesn't work since that
> is the request coming IN but I have to add it to the request going OUT.
>
Save the data in the user's session. When the servlet receives the following
request, grab the data out of the session and then call session.removeAttribute()
to remove it -- that way you won't accumulate any objects that are not needed any
longer.
>
> Can anyone help?
>
> Kind regards, Stefan Freyr.
>
Craig McClanahan
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets