On Thu, 13 Jan 2000, Bail . Jeff wrote:
> If I instantiate a bean:
>
> <jsp:useBean id="beanId" scope="session" class="BeanClass" />
>
>
> Shouldn't I be able to do something like:
>
> <%
> BeanClass newBean = new BeanClass();
> newBean.setName("New Name");
> beanId = newBean;
> %>
>
>
> At this point, on all subsequent pages I would expect that if I were to use
> the same jsp:useBean tag the object I would get back would be newBean. But
> this doesn't seem to be the case -- it always returns the original bean
> (which does not have the Name propery set). Are you actually allowed to
> change the object reference in this way?
The beanId local variable is just a copy of the session variable (see the
source code that's created for the useBean tag). It goes out of scope at
the end of the method and its value is NOT automatically copied back to
the session. You'd need to replace the session variable (using
session.setAttribute(...), for example) to accomplish what you want.
John K Peterson -- IT Services Development -- Brigham Young University
Internet: [EMAIL PROTECTED] Phone: (801) 378-5007
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
FAQs on JSP can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html