Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes Servlets and the fly likes Modifying a Bean Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Modifying a Bean" Watch "Modifying a Bean" New topic
Author

Modifying a Bean

Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

If I have a bean in a session, and in a servlet I get an instance of that bean, modify the parameters, do I then need to add the bean back to the session or will the session object contain the new values?
So for example
MyBean bean = (MyBean)session.getAttribute("mybean");
bean.setA("A");
bean.setB("B");
Now, at this point, do I need to do:
session.setAttribute("mybean", bean);
or not...
Thanks.


GenRocket - Experts at Building Test Data
Steve Leach
Ranch Hand

Joined: Sep 24, 2003
Posts: 46
You don't need to save the bean back. You are working with a reference to the original bean.
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

Great, thanks Steve.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Modifying a Bean
 
Similar Threads
can I get the request object in managed bean?
How do i invoke a bean from a servlet?
Why is this piece of code required from a servlet
Running an application bean method automatically on start?
Using Session Bean Info in a server