This week's book giveaway is in the General Computing forum.
We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum 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
Register / Login


JavaRanch » Java Forums » Java » Servlets
Reply Bookmark "session casting problem...." Watch "session casting problem...." New topic
Author

session casting problem....

mike vas
Greenhorn

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.....

mike
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

See:
http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Object.html#clone()


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

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: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: session casting problem....
 
Similar Threads
How to put all user info into session?
session casting problem....
How can a bean to get a object in application scope
Saving session information on session timeout
ActionContext and Session Objects