Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Storing Objects URGENT

 
Syed Kamran Ali
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the best possible way of storing objects,
in session or in cookies.
 
vishal avad
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
Best way to store objects is a HttpSession and not cookies as cookies reside on client computers and not trusted also they dont work when disabled.
HIH
Cheers
Vishal
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13064
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also there is a size limit on cookies and for anything besides String objects you would have to encode the object somehow.

Why do some people think that marking a post as "URGENT" will get them any more attention than a more informative title? I'm really curious about this.
Bill
 
Ryan Bailey
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why do some people think that marking a post as "URGENT" will get them any more attention than a more informative title? I'm really curious about this.

Good question Bill . Also you might want to change your name to match the one and only rule and it can be found in JavaRanches naming policy. If you store objects in Cookies (which I don't recommend) I believe they can only be of size 32K. Store them in the HttpSession..
Cheers,
Ryan
 
Cindy Glass
"The Hood"
Sheriff
Posts: 8521
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you Ryan .
OK - now to make it official
k1ndkam,
Please change your name to be compliant with JavaRanch's naming policy. It should not be obviously fictitious.
Your displayed name should be 2 separate names with more than 1 letter each. We really would prefer that you use your REAL name.
You can change your name: here.
Thanks,
Cindy
 
Bruce Jin
Ranch Hand
Posts: 672
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you need to store objects across sessions or applications, you can store them in servletContext.
 
sandy gupta
Ranch Hand
Posts: 228
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Say that again,
If u store anything in the session and servlet context, its the same thing. I do not think so. All the objects that are stored in the servlet context will be available to the resources in that servlet context and not to resources outside that while as the session variable will be available to all the applications irrespective of their servlet contexts.
Is that right.
???
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13064
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Briefly - NO!
Sessions are only shared within a "web application" which equates to a servlet context.
The servlet API originally had some methods that were more liberal but they got removed due to security concerns.
The original post was not clear on the scope that the objects were to be visible in. You have several choices, the whole application with ServletContext, the user's session with HttpSession and the individual request with objects attached to the ServletRequest and probably some more I have not thought of
Bill
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic