when u have already created a session and want to u that session in ur
future pages, use

req.getSession(false)//Pls Note here false instead of true.

>From jsdk2.1 docs
------------------

                --Start of Snip--
Returns the current HttpSession associated with this request or, if
necessary, creates a new session
for the request. Use true for create to create a new session, or false to
return the current         HttpSession.

If create is false and the request has no valid HttpSession, this method
returns null.

To make sure the session is properly maintained, you must call this method
at least once before you
write any output to the response. Newly created sessions (that is, sessions
for which
HttpSession.isNew returns true) do not have any application-specific state.

Parameters:
        true - to create a new session for this request; false to return the
current session
Returns:
        the HttpSession associated with this request or null if create is
false and the request has no
      valid session

                                --End of Snip--
Hope this helps
Srini

-----Original Message-----
From: tong rong [mailto:[EMAIL PROTECTED]]
Sent: Monday, July 31, 2000 11:54 AM
To: [EMAIL PROTECTED]
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