session value in java

S

sinhak.alok

First, I send user id from jsp page to servlet. That value received
on servlet page like this :-
String username = request.getParameter("user");
Then creating the session true on servlet like this:-
HttpSession session = request.getSession(true);
After that I set the value using setAttribute method
session.setAttribute("user_id", username);
When I receiving session value using getAttribute method it display
null on jsp page. my code is:-
String usercode = (String) session.getAttribute("user_id");
I am using Oracle JDeveloper 10g Relaese 2 as Editor.
 
L

Lew

When I receiving session value using getAttribute method it display
null on jsp page. my code is:-
String usercode = (String) session.getAttribute("user_id");

Eschew scriptlet in JSPs. Consider using ${ user_id } instead.

I have seen firewall software prevent establishment of a session, although I'm
not sure how it did that. Updated firewall policies fixed that problem.

You don't show the part that displays the value. The one line of code you
posted for session retrieval doesn't show the source of the problem.

Are you able to see the session variable through the debugger?

-- Lew
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top