2 Replies Latest reply on Oct 19, 2004 5:48 AM by Thomas Rickal

    Problem with storing a value into session object

    thoste Newbie

      When I call a JavaServerPage with the following simple code I got a NullPointerException.
      I just want to store the current date into a variable inside the session object.

      <%@ page import="java.util.*" %>
      <% session = request.getSession(true);

      String firstVisit = (String) session.getAttribute("firstVisit");
      if (firstVisit.equals("")) {
      session.setAttribute("firstVisit",(new Date()).toString());
      firstVisit = "new session"; }

      First Visit: <%= firstVisit %>
      I don't believe that the error is because of the "new Date()" code. It seems to be a more general problem.
      Do I have to add some more page import statements ?