Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Regarding session  RSS feed

 
Antonio Giovanni
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,..

I have a question regarding HttpSession.

Suppose i put a data object like Employee in the session like..

session.setAttribute("employee", emp)
where emp is an instance of Employee class

and in some other servlet or somewhere else in the code i
update one of the properties of the Employee instance .. like

(session.getAttribute("employee")).setLocation("something")

After this, for the update to reflect in any other place, do i have to re-put the Employee instance in the session or that is not required??

I mean do i have to once again have this code after making a change to the property session.setAttribute("employee", emp)

I appreciate your help in this matter.
As far as i understand i do not have to put the instance again in the session, for the change to show up in the code anywhere.

Thanks


PS: I hope my wording is understandable
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65830
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
do i have to re-put the Employee instance in the session or that is not required?


No, it is not required. Your employee instance is not really in the session to begin with. The session is merely maintaining a reference to the instance that you "added" to the session with setAttribute().
 
Antonio Giovanni
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear,

Thank you very much

The session is merely maintaining a reference to the instance that you "added" to the session with setAttribute().


The above statement gives a very good understanding.
Thanks again
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!