Link to home
Start Free TrialLog in
Avatar of wired_up
wired_up

asked on

Accessing a session variable in javascript

I am using java servlets to create the main body of a html page, in this session variables are set for login information:

HttpSession session = request.getSession(true);
session.putValue("userCode", lsUserCode);
session.putValue("password", password);

response.sendRedirect("/index_main.html");

Then later on one of the i want to check if the user's session is still active, i want to do with within the javascript, can i do this?
 -i have been doing :

var userCode = session("userCode");

but the javascript dosn't seen to reconise the session variable, i get the error message - "object expected".

Any help would be appreciated.

Thanks
:-)
Avatar of thanassis
thanassis

in your javascript try this:

var userCode = <%=session("userCode")%>
ASKER CERTIFIED SOLUTION
Avatar of jarasa
jarasa
Flag of Spain image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Also the page  you want to create must be a jsp page, not an html