This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
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
Author

session tracking------urgent

Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
hi,
in session.putValue() can i put an array of strings.
if yes ,then how do i typecast in session.getValue().
String[]names;
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.
thanks
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12791
    
    5

>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");
Bill
Anonymous
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().
regards,
vnk
 
GeeCON Prague 2014
 
subject: session tracking------urgent