This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Servlets and the fly likes session casting problem.... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "session casting problem...." Watch "session casting problem...." New topic

session casting problem....

mike vas

Joined: Dec 19, 2006
Posts: 5
Hi all,

I have the following code:

User user = new User();
user = (User)session.getAttribute("user");

Can anyone tell me how I can 'copy' the session object to 'user' so I can change the values of 'user' without changing the values of the object in the session..?
In the code above when I change a value in 'user' this is reflected to the session object.

thanks in advance.....

Ben Souther

Joined: Dec 11, 2004
Posts: 13410


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Ben Souther

Joined: Dec 11, 2004
Posts: 13410

Since copying/cloning objects is not a servlet specific issue..
Moving to Java In General (Intermediate).
I agree. Here's the link:
subject: session casting problem....
Similar Threads
Saving session information on session timeout
How to put all user info into session?
How can a bean to get a object in application scope
session casting problem....
ActionContext and Session Objects