Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Modifying a Bean

 
Gregg Bolinger
GenRocket Founder
Ranch Hand
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Steve Leach
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Great, thanks Steve.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic