You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Anand Prasad <ap...@calient.net> on 2000/10/11 03:22:14 UTC

Creating and Handling Session variables in jakarta

Hi All,

I am using Apache and Jakarta.  I would like to create session variable for
each user so that I can have them for the life of the session.

Here Snippet of my code in login.jsp
	
	try{
	      boolean hasAccess = login.checkPassword(userId , passwd);
   	     
                  if(hasAccess){
		/* Get the revelant information about the user & create
		   session variables */
		
		//HttpSession session = request.getSession(true)

		HttpSession session = request.getSession(false);
		session.putValue("loginId", userId);
		response.sendRedirect("index2.html"); 
		}
		else{
			response.sendRedirect("invalidlogin.jsp");
		}
	}


request.getSession(false) will give me the existing session.  I am getting
session already exists.  If I changed to request.getSession(true) it is
gives me error saying that session already exists.

Could anyone kindly explain me how does tomcat handle sessions.   My Goal is
to create 5 session variable for each session and use it in every page.

Thanks in Advance.

--Anand