Java Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesJava Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old April 23rd, 2001, 04:38 AM
Shiju Rajan's Avatar
Shiju Rajan Shiju Rajan is offline
.Net Developer
Dev Shed Novice (500 - 999 posts)
 
Join Date: Feb 2000
Location: London
Posts: 987 Shiju Rajan User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 26 m 22 sec
Reputation Power: 14
Send a message via MSN to Shiju Rajan Send a message via Yahoo to Shiju Rajan
Question

Hi,
i created a session in servlet.but i don't know how it get that back.i created sesion like session.putValue("name","value"); ..session is creating successfully..please tell me how do i get that session value back.

Thanks

Reply With Quote
  #2  
Old April 23rd, 2001, 06:57 AM
fae fae is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2001
Location: Helsinki, Finland
Posts: 1 fae User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Use session.getAttribute("name") to access it (as Object, so typecast).

And don't use putValue(), it deprecated. Use setAttribute(name,value) instead.

Good place for documentation
http://java.sun.com/products/servlet/2.2/javadoc/index.html
Comments on this post
JimmyGosling agrees!

Reply With Quote
  #3  
Old April 23rd, 2001, 12:30 PM
perlfaqs perlfaqs is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2001
Location: surat
Posts: 0 perlfaqs User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via Yahoo to perlfaqs
hi rajan

Ok u created the session with session.putValue function now if u wann to get the values from the session then use this one:


session.getValue("Session_name",value);

this is one function what i m using for retrieving values from the session..... if u wann more then contact me

bye
Comments on this post
JimmyGosling agrees!

Reply With Quote
  #4  
Old April 24th, 2001, 04:06 AM
fae fae is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2001
Location: Helsinki, Finland
Posts: 1 fae User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Hmm... i don't think there's such method, getValue("name",value). It's getValue("name") and it returns an object.

And those two (set/getValue) are deprecated so don't use those. Use set/getAttribute instead (assuming you have 2.2 sdk...).

Reply With Quote
  #5  
Old April 24th, 2001, 09:02 AM
perlfaqs perlfaqs is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2001
Location: surat
Posts: 0 perlfaqs User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via Yahoo to perlfaqs
Check this fae

There is something wrong with that code what i wrote.

But actually this is right way to get the session values from the session:


here is first jst getting the object from session:

public Object HttpSession.getValue(String name) here is class and code for this is here:

String name = (String)session.getValue("Session id");

and if u wann to get the all elements from the session that u put before then try this:

String[] values = session.getValueNames();
for (int i=0; i<values.length; i++) {

out.println(values[i] + ": " +session.getValue(values[i]));
}


Check work or not

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesJava Help > How to retrive a session value?

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap