Pls...Anybody help me...asap

i'm developing an Intranet mailing system using JSP. I want use the userid throughout my session. For that, i'm using the implicit 'session' object in JSP, as shown below..String usrname=request.getParameter("username"); if(session.isNew()) session.putValue("Username",usrname); I'm writing this code in a file, say login.jsp I want to use that 'usrname' throughout my session, until session is invalidated. In another file, say inbox.jsp i want to use that userid. For that i'm retrieving the value stored in the session as follows.. String userid=(String)session.getValue("Username"); out.println("<b>"+userid+"</b>"); But i'm getting a null value when I use the above statement. Instead I should get the userid that is entered by the user during login.... Why Am I getting a null value, where in I should get the username? Pls tell me where did I go wrong.. Reply asap.. Waiting for the help.. regds, Sandeep.

Did you create the session first by sending true to the constructor? Bosun

Bosun (SCJP, SCWCD).
So much trouble in the world -- Bob Marley

Raukutam Sandeep

Ranch Hand

Posts: 61

posted 17 years ago

hi,

is this the correct way of passing true to the constructor? session=request.getSession(true); If it is wrong pls tell me the correct way.. And did I go wrong in the code in my previous query.. Pls reply asap.. regds, Sandeep.

Raukutam Sandeep

Ranch Hand

Posts: 61

posted 17 years ago

hi,

is this the correct way of passing true to the constructor? session=request.getSession(true); If it is wrong pls tell me the correct way.. And did I go wrong in the code in my previous query.. Pls reply asap.. regds, Sandeep.

Is the file login.jsp the form where the user enters their userid? If so, I don't think the getParameter will return anything, because it is actually running before the user has input any value. I have my login setup like this. login.jsp - screen to capture login info, once they hit login button, I send them to menu.jsp menu.jsp - screen to getParamater from login.jsp and validate the user info. if they are not validated, I send them back to login.jsp. If they are validated, it then store the info in a session variable using the session.setAttribute. It should then be available until the session ends. Good luck! Jason.

Raukutam Sandeep

Ranch Hand

Posts: 61

posted 17 years ago

hi everybody,

sorry, for the trouble I gave u. The session is working fine now and I'm able to retrieve the username throughout the session. Thanx again, Sandeep.