You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Vijay Kandy <Vi...@mailcode.com> on 2004/04/01 17:50:37 UTC

Session replication

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


RE: Session replication

Posted by "Filip Hanik (lists)" <de...@hanik.com>.
hi Vijay,
sorry to let you know that I don't have bandwidth to support session
replication on Tomcat 4 as it was not part of the official release

The latest code base is at
http://cvs.apache.org/~fhanik/

is that what you are using?

Filip

-----Original Message-----
From: Vijay Kandy [mailto:VijayK@mailcode.com]
Sent: Thursday, April 01, 2004 9:51 AM
To: 'Tomcat Users List'
Subject: Session replication


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
---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.614 / Virus Database: 393 - Release Date: 3/5/2004

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.614 / Virus Database: 393 - Release Date: 3/5/2004


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