Bonjour,

I have a session problem within an application.
The servlet waiting on the URL of the application, while contacted,
opens a session and does a forward to another servlet. This one checks
the session and does a forward to another servlet, as well. The third
servlet checks the session. 
Which all works fine.
But, if the third servlet invalidates the session (or Tomcat times it
out), when reloading the first servlet, the third servlet doesn't find
any session.

The code below illustrates the problem.
You need to call the URL of the first servlet twice in order to
visualize the problem.

Thank you for any help,

Michel Lastes

config: jakarta-tomcat-3.2.1 on debian linux 2.2.17 

code: VerifSession1.java 
************************
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class VerifSession1 extends HttpServlet {

  public void init(ServletConfig config) throws ServletException {
      super.init(config);
  }

  public void doGet(HttpServletRequest req, HttpServletResponse res)
                               throws ServletException, IOException {
      HttpSession session= req.getSession(true);
      ServletContext sc=getServletConfig().getServletContext();

      System.out.println ("debut dans VerifSession1");

      if (session == null){
          System.out.println ("VerifSession1, session est nulle");
      }else{
          if (session.isNew()){
              System.out.println ("VerifSession1, nouvelle session");
          }  
          System.out.println ("VerifSession1, session est pas nulle");
      }
      System.out.println ("VerifSession1, j'appelle VerifSession2");
     
sc.getRequestDispatcher("/servlet/VerifSession2").forward(req,res);
      System.out.println ("fin dans VerifSession1");
  }
} 
 
code: VerifSession2.java 
*****************************
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class VerifSession2 extends HttpServlet {

  public void init(ServletConfig config) throws ServletException {
      super.init(config);
  }

  public void doGet(HttpServletRequest req, HttpServletResponse res)
                               throws ServletException, IOException {
      HttpSession session= req.getSession(false);

      ServletContext sc=getServletConfig().getServletContext();
      System.out.println ("debut dans VerifSession2");
      if (session == null){
          System.out.println ("VerifSession2, session est nulle");
      }else{
          System.out.println ("VerifSession2, session est pas nulle");
      }
      System.out.println ("VerifSession2, j'appelle VerifSession3");
     
sc.getRequestDispatcher("/servlet/VerifSession3").forward(req,res);
      System.out.println ("fin dans VerifSession2");
  }
} 
 
code: VerifSession3.java 
************************
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class  VerifSession3 extends HttpServlet {

  public void init(ServletConfig config) throws ServletException {
      super.init(config);
  }

  public void doGet(HttpServletRequest req, HttpServletResponse res)
                               throws ServletException, IOException {
      HttpSession session= req.getSession(false);

      ServletContext sc=getServletConfig().getServletContext();
      System.out.println ("debut dans VerifSession3");
      if (session == null){
          System.out.println ("VerifSession3, session est nulle");
      }else{
          System.out.println ("VerifSession3, session est pas nulle");
          System.out.println ("VerifSession, j'appelle
session.invalidate()");
          session.invalidate();
      System.out.println ("fin dans VerifSession3");
      }
  }
}

--
To unsubscribe:   <mailto:[EMAIL PROTECTED]>
For additional commands: <mailto:[EMAIL PROTECTED]>
Troubles with the list: <mailto:[EMAIL PROTECTED]>

Reply via email to