dcsimg
How do I re-assign a property on a JavaBean using <jsp:useBean> with scope="session"?
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Alvin_Lim
Posted On:   Thursday, September 13, 2001 08:54 PM

How do I re-assign a property on a JavaBean using with scope="session"? When I instantiate a session bean using JSP as such : with a setter method on the bean : class someBean { .... public void setA(String s) { System.out.println("Setting property A "); this.a = s; } it works the the first time the bean is instantiated with the following value posted : But when the same JSP page is called again, with the same attributes being posted but a different value, ie : the setter me   More>>

How do I re-assign a property on a JavaBean using with scope="session"?


When I instantiate a session bean using JSP as such :

			
				





with a setter method on the bean :


			
				
class someBean {
....
public void setA(String s)
{
System.out.println("Setting property A ");
this.a = s;
}




it works the the first time the bean is instantiated with the following value posted :




But when the same JSP page is called again, with the same attributes being posted but a different value, ie :




the setter method above is not called a second time. So the bean retains the orginal value of 1.


My question is :

1. Is this some property of a session bean?

2. If so, how do I re-assign a value on a session bean?


Thanx.    <<Less

Re: How do I re-assign a property on a JavaBean using &lt;jsp:useBean&gt; with scope="session"?

Posted By:   Govind_Seshadri  
Posted On:   Thursday, September 27, 2001 03:59 PM

Well, what you are seeing is the normal behavior of the tag with session scope. The body of the useBean is called only when the bean is instantiated, and this happens during the first request. After this, the useBean basically obtains a previously existing reference from the session scope.


If you need to execute the body for every request, set scope=request within your useBean tag.

About | Sitemap | Contact