query

Hi all, I wanted to know session.getAttribute function returns object ref or a copy of object..if returned object is changed will that reflect without setting it back in session.
[199 byte] By [saravanan.chennaia] at [2007-11-27 5:46:13]
«« query
»» Graphics 2D
# 1
AFAIK, it makes no difference what you do to the object you've got from the session, the object in the session will not be changed.
nogoodatcodinga at 2007-7-12 15:28:45 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2
everything in java is a reference. So if you do this:Person person = (Person) session.getAttribute("person");person.setName("nogoodatcoding");This changes the object stored in the session.
gimbal2a at 2007-7-12 15:28:46 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3
are you sure it will reflect?i am updating a session object exactly the way you have said.. but it is not reflected in other page. ;((
saravanan.chennaia at 2007-7-12 15:28:46 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 4
are you sure it will reflect?i am updating a session object exactly the way you have said.. but it is not reflected in other page. ;((
saravanan.chennaia at 2007-7-12 15:28:46 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 5

> everything in java is a reference.

I get that but it doesn't seem to work that way; I tried it out a bit.

Also, consider that you get some object from the session. Then you manipulate this object, say to display it, then the session object would also reflect the change! And you don't want that to happen always!

So I dunno if this is how its supposed to be.

Also, question, does casting create a new object? Just realized I have no idea if it does or not. Because if it does, then that might explain why instead of working with the original object that is referenced in the session, we're working with a new one.

nogoodatcodinga at 2007-7-12 15:28:46 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...