It's not a secret anymore!
The moose likes Servlets and the fly likes session tracking------urgent Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "session tracking------urgent" Watch "session tracking------urgent" New topic

session tracking------urgent

Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
in session.putValue() can i put an array of strings.
if yes ,then how do i typecast in session.getValue().
HttpSession session;
session.putValue("xyz", names) - is it valid ?
if yes then how do i retrieve names

names = (?)session.getValue("xyz");
if no then any other way like vector etc. to pass a related data
in session tracking.
William Brogden
Author and all-around good cowpoke

Joined: Mar 22, 2000
Posts: 13027

>session.putValue("xyz", names) - is it valid ?
Sure, why wouldn't it be, arrays are all Objects, you can cast
Object obj = names ;
>if yes then how do i retrieve names
Use the same notation you would use to declare a String array:
names = (String[])session.getValue("xyz");
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
hi William,
thank you.initially i did the same and got an error ,so,tried it with vector and it worked.may be in the first case i made a mistake while using the values in the doGet()method.
Strings are real headache except when they are used in println().
I agree. Here's the link:
subject: session tracking------urgent
jQuery in Action, 3rd edition