Meaningless Drivel is fun!*
The moose likes Servlets and the fly likes Storing Objects URGENT Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Storing Objects URGENT" Watch "Storing Objects URGENT" New topic
Author

Storing Objects URGENT

Syed Kamran Ali
Greenhorn

Joined: Jun 16, 2002
Posts: 12
What is the best possible way of storing objects,
in session or in cookies.
vishal avad
Ranch Hand

Joined: Nov 29, 2001
Posts: 45
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

Joined: Mar 22, 2000
Posts: 12806
    
    5
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

Joined: Feb 26, 2002
Posts: 134
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


SCJP 1.4, SCWCD
Java: The power, elegance, and simplicity of a hand grenade
Cindy Glass
"The Hood"
Sheriff

Joined: Sep 29, 2000
Posts: 8521
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


"JavaRanch, where the deer and the Certified play" - David O'Meara
Bruce Jin
Ranch Hand

Joined: Sep 20, 2001
Posts: 671
If you need to store objects across sessions or applications, you can store them in servletContext.


BJ - SCJP and SCWCD
We love Java programming. It is contagious, very cool, and lot of fun. - Peter Coad, Java Design

Crazy Bikes created by m-Power
sandy gupta
Ranch Hand

Joined: Jan 30, 2001
Posts: 228
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.
???


Adios
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12806
    
    5
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Storing Objects URGENT