tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Nicolas Gauthier <gauth...@azalee.cst.cnes.fr>
Subject Session problem
Date Thu, 26 Oct 2000 13:42:27 GMT
Hi,

I am using Tomcat and a JDK1.2.2 virtual machine.

I need to use HttpSession to maintain light session information on the server.
But I have an inconsistency in the way it seems to be (not) working. It must be
a simlpe problem, or at least a wall known one.

It goes like this:

1) the client does a GET on a simple jsp login page. No session is created
there by the application code, but Tomcat must create a session to run the jsp
I think, so a cookie is associated to the HttpResponse, with a JSESSION value
(say To1At for instance).

2) Once the user has entered his login password info, it is checked on the
server by a servlet LoginServlet. If success, I THEN create an applicative
session doing

------------------
    HttpSession session = request.getSession(true);

     session.putValue(PARAM_LOGIN, request.getParameter(PARAM_LOGIN));
     session.putValue("listener", ServicesMgr.instance());

     response.sendRedirect(CnesHttpUtils.buildUrl("services/watcher/frame.html"
, false));
-------------------

I check this session Id and it is the same than the one created during the
access of the jsp: To1At


3) Any other access to a servlet goes first throught a topServlet
'checkSession() method' which checks that the request is associated with a
valid session:


-------------------
checkSession(request, response):

 HttpSession session = request.getSession(false);

  Cookie[] cookies = request.getCookies();
  String cook = "Cookies List: \n";

  if (cookies.length != 0)
  {
       for (int i = 0 ; i < cookies.length; i++)
       {
            cook = cook + "Numero " + i + ": (" + cookies[i].getName() + " , "
+ cookies[i].getValue() + ") ,  \n";
            HERE I ALWAYS GET A JSESSION COOKIE WITH A DIFFERENT VALUE FROM THE
ONE SET IN THE PREVIOUS STEP: WHY ?????
       }

  }

    Trace.debug(this,cook);                // Personnal Trace facilitie.

// HERE I TEST THE SESSION
  if (  (session == null)  ||  (session.getValue(PARAM_LOGIN) == null) )
  {

   if (session == null)
   {
        Trace.debug(this, " Session non valide: aucune session serveur n'est
associƩe a la requete;");
   }
   else
   {
        Trace.debug(this, " Session exist : "  + session.getId()) ;
        Trace.debug(this, " But no object PARAM_LOGIN in it") ;
        OF COURSE SINCE THE SESSION OBJECT DIFFERS FROM THE ONE I HAVE CREATED,
NO APPLICATIVE OBJECT IS STORED IN IT ...
   }

------------------------


The urls that  are access during the process are all rigourously the same: same
server, same path, same port. So there is no reason why the first cookie sent
back: To..1At.




Is it a Tomcat bug, or is there something I do wrong ? This is basically the
same code I use to use with Jrun last year, and it was working fine.


Does anyone know about a possible answer ?

Thanks,

Nicolas.


Mime
View raw message