This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Soft Skills and have John Sonmez on-line!
See this thread for details.
The moose likes Servlets and the fly likes session vs class variables Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "session vs class variables" Watch "session vs class variables" New topic
Author

session vs class variables

Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
Whatis the difference between session variables and using class variables? For exampe, if I have a class variable in my servlet that gets modified in the code, its new value gets carried to the next time the servlet is invoked. So why would I want to ever use a session variable if it seems the class variable holds data through various requests?
Thanks
Brian
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
Session variables are browser client - server specific, i.e for each and every session of the browser with the server u have a set of session variables at ur disposal.so one set of session variables for client session may have entirely different values from that of the other session values.
If we have the class variable in the server,then the value of the variable will be same for all the browser sessions.
Mainly session variable are used for security purpose,once the client server connection is lost session variables of that instance is also lost...
hope this answers the question,
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: session vs class variables