开发者

Force session replication in Tomcat 5.5

I am runnig a web application on tomcat 5.5.

How can I force dump of a session into disk

  1. on each request

  2. on each int开发者_Go百科erval of time


Question 1 could be done using a filter or valve:

    public void doFilter(ServletRequest request, ServletResponse response,
                FilterChain chain) throws java.io.IOException, ServletException {
            HttpServletRequest req = (HttpServletRequest) request;
            HttpServletResponse res = (HttpServletResponse) response;
            HttpSession session = req.getSession(false);
            if(session != null) {
            dumpSession( session );
            }
            chain.doFilter(request, response);
        }
}

For Question 2 see this discussion


Look at Persistent Manager http://tomcat.apache.org/tomcat-5.5-doc/config/manager.html Setting maxIdleBackup and maxIdleSwap to 0 or near-zero time would persist session on every request. Setting these parameters to bigger value will give You dump in intervals.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜