|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now! |
|
#1
|
||||
|
||||
|
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 |
|
#2
|
|||
|
|||
|
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 |
|
#3
|
|||
|
|||
|
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 |
|
#4
|
|||
|
|||
|
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...). |
|
#5
|
|||
|
|||
|
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 |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Java Help > How to retrive a session value? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|