JSP Problem ussing implicit object (session) in a function

Posted by user234666 on Stack Overflow See other posts from Stack Overflow or by user234666
Published on 2009-12-18T16:45:13Z Indexed on 2010/03/24 16:03 UTC
Read the original article Hit count: 211

Filed under:
|
|
|

Can the object of type HttpSession called session be accessed from a function?

In a simple jsp page I have a function(see below) defined in the header of the page, and set to an onclick handle of for a button. When I press this button, I'll never see the second alert message. If I do something in the body of the page (like Session ID: <%= session.getId() %> ) I have no trouble accessing it. What newbie mistake am I making?

     function doTest()
 {
  alert('Preforming test 122333232');

      String sessionId = session.getId();

      alert('After access');

      if(sessionId == null)
      {
        alert('session id is null?');
      }

Thanks

© Stack Overflow or respective owner

Related posts about jsp

Related posts about session