aspose file tools*
The moose likes Servlets and the fly likes Can We Store Something Other Than An Object In A Session? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Can We Store Something Other Than An Object In A Session?" Watch "Can We Store Something Other Than An Object In A Session?" New topic
Author

Can We Store Something Other Than An Object In A Session?

JiaPei Jen
Ranch Hand

Joined: Nov 19, 2000
Posts: 1309
I have seen how to store an object in a session and the syntax is

and we usually put String(s) in that object; for example, we have a customer object and we do the following:

Is it possible to store a String in a session? What if I only want to store a String "origin" in a session so that this String can be passed to all subsequent requests?
Andres Gonzalez
Ranch Hand

Joined: Nov 27, 2001
Posts: 1561
JiaPei -
Guess what?
A String is an Object !! . So yes, you can put a String object in the session.
Just remember that when you use session.getAttribute("yourParameter"), it'll always return an Object, so you'll have to typecast it to a String.


I'm not going to be a Rock Star. I'm going to be a LEGEND! --Freddie Mercury
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Can We Store Something Other Than An Object In A Session?