• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

session creation

 
Ranch Hand
Posts: 164
Android Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I'm creating session as session.setAttribute("arg",obj);.
Suppose I add the bellow code after create session.
session.setAttribute("arg",newObj);
Now which object will be returned when I use "session.getAttribute("arg");" either (obj) or (newObj)
 
Ranch Hand
Posts: 5575
Eclipse IDE Windows XP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
what do you find when you test this ?
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Vinoth Thirunavukarasu wrote:Hi,
I'm creating session as session.setAttribute("arg",obj);.

Correction: that creates a scoped variable named arg in the session -- it does not create a session.

Seems easy enough to try out. As seetharaman asked, what happened when you tried it?
 
Vt Guru
Ranch Hand
Posts: 164
Android Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When I try this I got the newest object not the old one. But I don't know the old session object is destroyed or not.
 
Bartender
Posts: 4116
72
Mac TypeScript Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Vinoth Thirunavukarasu wrote:When I try this I got the newest object not the old one. But I don't know the old session object is destroyed or not.



Well, what actually you are trying to do? Do you need the old session object or a new one always? For that we need to look at how you create the object.
 
Vt Guru
Ranch Hand
Posts: 164
Android Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for your reply,

I want the new session object. My question is what will happened to old session object whether it will deleted from session or not.
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Vinoth Thirunavukarasu wrote:When I try this I got the newest object not the old one. But I don't know the old session object is destroyed or not.


Again, please use correct terminology. An object you place in session scope is called a scoped variable.

When you add the new scoped variable, the reference to the old one is removed. That object is then subject to garbage collection according to the rules of Java.
 
reply
    Bookmark Topic Watch Topic
  • New Topic