It's not a secret anymore!*
The moose likes Servlets and the fly likes how can I set multiple attributes to a session object. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "how can I set multiple attributes to a session object." Watch "how can I set multiple attributes to a session object." New topic
Author

how can I set multiple attributes to a session object.

Ramu Rondla
Greenhorn

Joined: Oct 04, 2003
Posts: 9
hello friends,
I am developing an e-commerce application. I have a question related to sessions.
I am creating a session like this
HttpSession session = request.getSession(true);
and I can set one attribute (session.setAttribute(name, value)).
but how can I set multiple attributes to this session object.
for example, when the session is created it should set the username and password.
Thanks,
Ramu
Andres Gonzalez
Ranch Hand

Joined: Nov 27, 2001
Posts: 1561
but how can I set multiple attributes to this session object.
session.setAttribute(name1, value1)
session.setAttribute(name2, value2)
session.setAttribute(name3, value3)
and so on....
if you want to have a single object that holds multiple variables you can easily store it in the session (array, hashtable, anything that is an object)


I'm not going to be a Rock Star. I'm going to be a LEGEND! --Freddie Mercury
Ramu Rondla
Greenhorn

Joined: Oct 04, 2003
Posts: 9
Thank You Gonzalez.
P. Udaya Shankar
Greenhorn

Joined: Nov 18, 2003
Posts: 21
hi,
u put all the values in Hashtable, put that into session
r u can loop through ur values
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how can I set multiple attributes to a session object.
 
Similar Threads
ServletConfig
PLEASE HELP --- Java Newbie!!!
access data from multiple sessions
session listener
getting session value in JSP