"A.R.Karthikeyan" wrote:

> 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
> [...]

Hi :-)  I am not sure, but I think in other Servlets(which are not your
loginServlet),
you can use:
         ...
         HttpSession session = request.getSession(false);
         if (session == null) {
            response.sendRedirect(response.encodeUrl("/servlet/loginServlet"));
         return;
         }

        Object obj = session.getValue("login");
        if (obj == null) {
           response.sendRedirect(response.encodeUrl("/servlet/loginServlet"));
        return;
        }

        // other checking, for example, check if obj is a instance of the class
        // with which you made your *value* in your loginServlet.
        ...


Bo
Dec.01, 2000

___________________________________________________________________________
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