Rachel:
Just want to point out that "req.getSession(true)" will create a new session if
one doesnt already exist. If you want to make sure that a person doesnt get a
session unless they come in "through the front door" of your loginServlet, you may
want to do something like this:
session = req.getSession(false);
if (session == null) redirect to loginServlet;
else carry on.
Hope this helps.
Geeta
PS am in a rush so havent had time to carefully look at your code, so please let
me know if I have misunderstood your problem; shall have time to look at it later
tody..
tong rong wrote:
> 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