tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Vijay Kandy <Vij...@mailcode.com>
Subject Session replication
Date Thu, 01 Apr 2004 15:50:37 GMT
Hello,

This may seem trivial to most of you but I bet this will help learner like
me so heres my question. I use the following method to validate a http
session. I have 2 instance of Tomcat 4.1.24 + mod_jk + Apache2 that
replicate session in-memory (JavaGroups stuff). After I deliberately
shutdown one instance, I see that requests to the other instance but while
validating sessions I go to the line where I put block comments ("I get to
this line on Node 2 ...") and eventually invalidate() them. Why does
session.isNew() return true on the second instance? 


private boolean isValidSession(HttpServletRequest request,
HttpServletResponse response)
{
	try
 	{
 		HttpSession session = request.getSession(true);
		if( ! session.isNew() )
		{
			if( session != null )
			{
				Hashtable sessionStuff =
(Hashtable)session.getAttribute("someSessionStuff");

				try
				{
					// Do something with "sessionStuff"
...
				}
				catch(Exception exp)
				{
	
session.removeAttribute("sessionStuff");
					session.invalidate();
					return false;
				}
			}
			else
			{
				session.invalidate();
				return false;
			}
		}
		else
		{
			/************************************** 
			 * I get to this line on Node 2 ...
			 **************************************/
			session.invalidate();
			return false;
		}
	}
	catch(Exception e)
	{
		e.printStackTrace();
	}

	return true;
}

Regards,
Vijay Kandy

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


Mime
View raw message