Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
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

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
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: 12761

>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().
subject: session tracking------urgent
Similar Threads
deprecated session methods-need new???
how to count active sessions in Servlet 2.2 specification
Servlet session tracking on websphere.
Session Management