Thanks for everyones help on this...

I guess what I am wondering now is a bit different to my previous
question:

If my controller.jsp sets a request scope attribute before forwarding to
a new page (using <jsp:forward>), that attribute is available on the new
page:

ie if my controller.jsp says:

request.setAttribute("aMessageString", "This is a message");
and then forwards to a new page, I can then on the new jsp page say
<%= request.getAttribute("aMessageString") %>
and it will display my message on the screen.
This works fine.

If I set an instance of "myBean" as an attribute as in
request.setAttribute("myBean", myBean);

then I thought if I use the tag:
<jsp:useBean id="myBean" scope="request" class="package.name.myBean" />
then instead of creating a 'new' instance of myBean, it would find there
is already an attribute called myBean and would use that. Since the
myBean instance is populated with data, I could then use the
<jsp:getParameter> tag to display fields in myBean...

thanks for any more clarifications here
Joel

On Thu, 2002-10-31 at 00:01, Amit Ghaste wrote:
> I am assuming somethings here... if I am wrong... disregard
>
> ASSUMPTIONS:
> 1. the usebean is in ur jsp A which has a form which submits a request
> 2. the the request is posted to a controller... say a servlet B.
>
> now taking the http action into account a new request object is created when
> u do a post or a get operation.... so by the time when u post to the
> controller the bean has lost its instance...
>
> if u did something like this..
> <code>
> <jsp:usebean scope="request"...../>
> //then
> //forward to the servlet...... the request scope remains.... else it is lost
> //for ex.
> request.sendRedirect("/B");
> </code>
>
> REMEMBER>>>>>a request scope is lost
> 1. after u send a response back.
> 2. u dont forward the request forward.
>
> Hope that helps
> Amit
>
> -----Original Message-----
> From: A mailing list about Java Server Pages specification and reference
> [mailto:JSP-INTEREST@;JAVA.SUN.COM]On Behalf Of Joel Carklin
> Sent: Tuesday, October 29, 2002 2:50 AM
> To: [EMAIL PROTECTED]
> Subject: Basic jsp:useBean question
>
>
> Hi,
>
> if I use the following tag in my jsp:
>
> <jsp:useBean id="myBean" scope="request" class="package.name.myBean" />
>
> When I click on the submit button on my form, the 'request'
> is POSTED to a 'controller' jsp, which passes the 'request' onto a
> request handler class.
> I expected that if I called request.getAttribute("myBean") from either
> the controller jsp or the request handler class, I would get the myBean
> instance created by the useBean tag above. But I always get null??
>
> thanks
> Joel
>

===========================================================================
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://archives.java.sun.com/jsp-interest.html
 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.jsp
 http://www.jguru.com/faq/index.jsp
 http://www.jspinsider.com

Reply via email to