u can just put
HttpSession hs = req.getSession(true);
for the first page alone.
this command creates a session if it already does not exist.
if it already exists it uses the existing session.
Basically a session is maintained by either a cookie which is
stored in the client or by url rewriting.
so once the session is established
in the first page in subsequent pages u can just get
the value by using
hs.getValue("login");
//where hs is httpsession object
then based on the value(whether it is null or there is some value) u can
proceed accordingly.
>From: "A.R.Karthikeyan" <[EMAIL PROTECTED]>
>Reply-To: "A mailing list for discussion about Sun Microsystem's Java
> Servlet API Technology." <[EMAIL PROTECTED]>
>To: [EMAIL PROTECTED]
>Subject: Session tracking
>Date: Fri, 1 Dec 2000 15:52:15 +0100
>
>Hi everybody,
>How can I maintain a session for a user who has logged in from the home
>page , across multiple HTML pages(links) generated by multiple servlet
>programmes?
>The very first page of the site is a login page and all the subsequent
>pages
>can be accessed only if the login is right.
>Once a user logs in correctly , a session is created using HttpSession sess
>= req.getSession(true)and i put the login value of the user in the session
>using sess.putValue("login",value).My question is now when the user clicks
>on the links of this page which are html pages generated by other servlet
>programmes ,should i use HttpSession sess = req.getSession(true) in each of
>these programmes to maintain the same session.If not how can i maintain a
>session for everyuser who logs onto to the site.
>To remind u -every page of the website is a protected resource.
>I've run into a state of confusion in this particular session maintenance
>scenario.
>Hope somebody would help me out with this with some clear suggestion and
>solution!
>Thanx in advance
>Karthikeyan A.R
>
>___________________________________________________________________________
>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
_____________________________________________________________________________________
Get more from the Web. FREE MSN Explorer download : http://explorer.msn.com
___________________________________________________________________________
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