aspose file tools*
The moose likes Servlets and the fly likes HttpSession and ServletContext - Difference? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "HttpSession and ServletContext - Difference?" Watch "HttpSession and ServletContext - Difference?" New topic
Author

HttpSession and ServletContext - Difference?

aatish pandya
Greenhorn

Joined: Apr 20, 2011
Posts: 21
I am unable to store a LinkedList in an HttpSession but can do with a ServletContext. why? what is the difference between the two?
srinivas srinivasmeenavalli
Ranch Hand

Joined: Jul 13, 2008
Posts: 65
What is the issue while stroring Linked list in HttpSession? Why you want to store in a session.
Session - values store with in a User session scope
ServletContext - Values store with in a servlet scope
Abhay Agarwal
Ranch Hand

Joined: Feb 29, 2008
Posts: 1105
    
    1

@Aatish - please post exact error/exception that you are facing while saving LinkedList in HTTPSession.

A very wild guess from my side -- are you facing NotSerializableException? if yes then please read on..
If your applicaion is clustered one (distributed), then all objects, which are supposed to be stored in HTTPSession, must implements Serializable interface. If you do not implement Serializable interface , then, notSerializableException is thrown. Below mentioned are the two old posts referring to same error
http://www.coderanch.com/t/286768/JSP/java/serializable-object-httpsession
http://www.coderanch.com/t/508632/Servlets/java/Serialization-HTTPSession-object

~ abhay
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: HttpSession and ServletContext - Difference?