httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Geoffrey.W.Halsted" <geoffrey.w.hals...@orcmacro.com>
Subject Re: [users@httpd] SESSIONS are NOT Maintained
Date Tue, 22 Apr 2003 13:59:03 GMT
Hari Om

Are you going between two different servlet contexts?  A session is set 
to null every time you visit a different servelt context.  

Hari Om wrote:

> Hello Everyone!
>
> I am using Servlets, JSP and JDBC for my Web Application.
>
> I am using SESSION Variables. My entry point is Login Screen 
> "www.man.com/proj/servlet/login" where user enters USERNAME/PASSWROD.
>
> This FORM calls PROCESS.JAVA Servlet which creates a SESSION for them 
> as shown:
> -----------------------------------------------------------------------
> HttpSession session = req.getSession(true);
> String uname = (String)session.getValue("uname");
>
> // code coonects to JDBC and see if they match
> // IF MATCH
>
> session.putValue("uname",req.getParameter("username"));
> String uid = "";
> uid = uid.valueOf(rs.getInt("uid"));
> session.putValue("uid",uid);
>
> //I then redirect to MENU Page ....which list options availabe for 
> this user.
> res.sendRedirect(menuURL);
> ---------------------------------------------------------------------
>
> on my menu page (MENU.JAVA), I have following:
> -----------------------------------------------------------------
> HttpSession session = req.getSession(true);
> String uname = (String)session.getValue("uname");
> String uid =   (String)session.getValue("uid");
>
> if (uname == null)
> {
>     PRINT ERROR.....
> }
> -----------------------------------------------------------------
>
> Later then user selects one of the MENU options and it takes to 
> another Servlet (say OPT1.JAVA)...
>
> OPT1 Servlet is processed and at the end it displays a LINK which will 
> take a User back to MENU.JAVA Page....
>
> But When users clicks this LINK (A HREF) it takes to MENU.JAVA Page 
> but shows UNAME as NULL...... How is it possible...? SHOULD IT NOT 
> RETAIN the SESSION....?
>
> HOW CAN I RETAIN my PREVIOUS Session Variables...?
>
> Any related informaiton on this is appreciated.
>
> THANKS!
>
>
>
>
>
>
> _________________________________________________________________
> The new MSN 8: smart spam protection and 2 months FREE*  
> http://join.msn.com/?page=features/junkmail
>
>
> ---------------------------------------------------------------------
> The official User-To-User support forum of the Apache HTTP Server 
> Project.
> See <URL:http://httpd.apache.org/userslist.html> for more info.
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>   "   from the digest: users-digest-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
>
>
>



---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Mime
View raw message