Manish Bhatnagar wrote:
>
> Try this out:
>   HttpSession httpSession = httpservletrequest.getSession(true);
>   String httpSessionId = httpSession.getId();
>   String sessionId = String.valueOf(httpSessionId);

Calling String.valueOf(httpSessionId) is unnecessary because
httpSessionId is ALREADY a String.

> You should pass the session id to each of the subsequent links in the
> application. That way you identify a unique request.

One may not need to explicitly pass the session id to each subsequent
link. If the client has cookies enabled, then the servlet container
automatically passes the session id. In this case, the programmer does
not need to do anything with the session id.

Only if the client does not support cookies does the session id need to
be appended to any links sent to the client. Again, though, the
programmer does not need to explicitly extract the session id. Adding
the session id is done by calling the HttpServletResponse method
encodeUrl(String url). Calling this method appends the session id to the
given url.

> As soon as the user logs
> out the session should be destroyed.

The server may not be notified when the user is done with the session.
The user may simply close the browser without logging out. In this case,
the session is invalidated after a certain amount of time. This is a
configurable feature of the servlet container.

> Balasubramanian S wrote:
>
> > Hi
> >         I need help from u .Iam using the servlets
> > Iam planning to keep track of session throughtout my application
> > I have used HttpSession  session = session.getSession(true)
> >
> > But for me it is not working for me .Please help me How to maintain
> > the session throught out application

Check out the tutorial:
http://java.sun.com/docs/books/tutorial/servlets/client-state/index.html

K Mukhar

___________________________________________________________________________
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