This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

HttpSession and ServletContext - Difference?

 
aatish pandya
Greenhorn
Posts: 21
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 65
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1375
Eclipse IDE Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@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
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic