updateServlet:
doGet()
{
    /* instead of true ..... it should be false.
        true will create a new session if one does not already exist.
        false will return an already existing session or null if one does
not exist */
     HttpSession session=req.getSession(false) ;
    If(session != null){
    String sessionId=session.getId();
    ....
    }
   else{
         /* session does not exist ..... handle by redirecting ....or flag
error */
        ......
    }
}

-----Original Message-----
From: tong rong <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED] <[EMAIL PROTECTED]>
Date: Monday, July 31, 2000 8:17 PM
Subject: session tracking problem in doGet


>Hi,
>   I am writing a servlet handler program. The process is: when user login,
my
>handler servlet read  login information and pass them to loginServlet, save
>loginServlet's sessionId and display result.  Then user can edit his
account
>through Get method of  'updateServlet '. My handler servlet will pass
>loginServlet's sessionId to updateServlet.
>    But when I use req.getSession(true) in updateServlet, what I got is
>different with the sessionid i sent.  Please help me.
>Here is my code:
>
> handlerServlet:
>public sendGetData(String lastCookie)
>{
>  URL url=new URL("/servlet/updateServlet?Change=add");
>   URLConnection con = url.openConnection();
>     con.setDoInput(true);
>     con.setUseCaches(false);
>     if(lastCookie!=null)
>        con.setRequestProperty("cookie", lastCookie);
>
>   InputStream in = con.getInputStream();
>   Reader reader = new InputStreamReader(in);
>   this.reader = new BufferedReader(reader);
>}
>
>updateServlet:
>    doGet()
>{
> HttpSession session=req.getSession(true) ;
>String sessionId=session.getId();
>....
>}
>
>Thanks in advance
>
>rachel
>
>___________________________________________________________________________
>To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
>of the message "signoff SERVLET-INTEREST".
>
>Archives: http://archives.java.sun.com/archives/servlet-interest.html
>Resources: http://java.sun.com/products/servlet/external-resources.html
>LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
>

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to