You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Hari Om <ha...@hotmail.com> on 2003/04/21 23:20:58 UTC

Sessions NOT Maintained

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!






_________________________________________________________________
STOP MORE SPAM with the new MSN 8 and get 2 months FREE*  
http://join.msn.com/?page=features/junkmail


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


RE: Sessions NOT Maintained

Posted by mike jackson <mj...@cdi-hq.com>.
Using IE6?  Check the privacy tab...  

--mikej
-=------
mike jackson
mjackson@cdi-hq.com

> -----Original Message-----
> From: Hari Om [mailto:hari_om@hotmail.com]
> Sent: Monday, April 21, 2003 1:21 PM
> To: tomcat-user@jakarta.apache.org
> Subject: Sessions NOT Maintained
> 
> 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!
> 
> 
> 
> 
> 
> 
> _________________________________________________________________
> STOP MORE SPAM with the new MSN 8 and get 2 months FREE*
> http://join.msn.com/?page=features/junkmail
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Re: Sessions NOT Maintained

Posted by "Francisco J. Bido" <bi...@mac.com>.
1.  Find out how your managing the session i.e., cookies or URLEncoding.

2.  If using cookies, then make sure your URLs are consistent between 
forwarding calls.  For example
"http://localhost:8080/myApp/myServlet" is not the same as 
"http://127.0.0.1:8080/myApp/myServlet"

You may just want to print out the session id as you transition between 
JSP/Servlets and see
where it's getting lost -the IDs should match.


On Monday, April 21, 2003, at 04:20  PM, 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!
>
>
>
>
>
>
> _________________________________________________________________
> STOP MORE SPAM with the new MSN 8 and get 2 months FREE*  
> http://join.msn.com/?page=features/junkmail
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org