Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to use pageContext to setAttribute for a session

843835Aug 13 2002 — edited Aug 13 2002
Hi,
I am new to pageContext.
I want to store value on pageContext so that it can be retrived through out session. Can anybody help me out how to proceed further.
I did in this way but when i am accessing the value set in the pageContext i am getting null value. Pls let me know if i am wrong somewhere. Even i have set session="true" during jsp initialization.
Do we require to set
session=request.getSession(true);
Even i tried it still its giving null value.

pageContext.setAttribute("userid","sachin",pageContext.SESSION_SCOPE);
pageContext.setAttribute("userpwd","abc123",pageContext.SESSION_SCOPE);
String uid=(String)pageContext.getAttribute("userid");
String pwd=(String)pageContext.getAttribute("userpwd");

when i print them it gives null values. Pls help me out. Its very very urgent.


thanks a lot,
sachin
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 10 2002
Added on Aug 13 2002
2 comments
956 views