Mark Hayes wrote:
> I should have explained that our situation involves the use of NAS (Netscape
> Application Server) using their failover mirroring and non-sticky load
> balancing. The bottom line with that stuff is, not only can session data
> use a lot of memory under heavy load, but the session data also needs to be
> replicated between servers for failover and load balancing. This means that
> session data adds up to a significant performance factor. For a
> single-server system, it would not be as significant and in that case adding
> as much memory (and setting the timeout to a longish interval) as possible
> may be the best strategy.
I see - that makes sense. I am using JServ with Tomcat and it uses a
different mechanism for load balancing which ties the user to the server
they started at. I guess they both have their pros and cons.
> Thanks, that is really helpful information. In which servlet implementation
> have you seen this happen? I naively assumed that the "unbound"
> notification would only take place when the value was explicitly set to null
> by the application, and I didn't test it :-(. If this happens on session
> timeout as well, that's perfect -- I can then write the session data to the
> database only when the session times out.
>
The 2.1 and 2.2 JSDK API's both share this. I've been using it in 2.2 and
it works great. Here's some sample code to test it out on your server
setup:
import java.io.IOException;
import javax.servlet.*;
import javax.servlet.http.*;
public class TestServlet extends HttpServlet
{
public void init(ServletConfig config) throws ServletException
{
super.init(config);
}
public void service( HttpServletRequest request, HttpServletResponse
response) throws ServletException, IOException
{
HttpSession session = request.getSession(true);
session.setMaxInactiveInterval(60);
TestClass tc = new TestClass();
session.putValue("TESTBINDING", tc);
}
public void destroy()
{
}
}
/****SAMPLE CLASS FOR TESTING ****/
import javax.servlet.http.*;
public class TestClass implements HttpSessionBindingListener
{
public void valueBound(HttpSessionBindingEvent evt)
{
System.out.println("TestClass has been bound to HttpSession");
}
public void valueUnbound(HttpSessionBindingEvent evt)
{
System.out.println("TestClass has been unbound from HttpSession");
}
}
>
> Thanks for your comments, they are very helpful.
> mark
>
As were yours - thanks
mike
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
FAQs on JSP can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html