tomcat redis integration and related jar packages

This article refers to
nginx+tomcat+redis to complete the session sharing

and copy it to $TOMCAT_HOME/lib after the completion of session sharing.

Modify the context.xml of the two tomcats:

<Context>  
  
    <!-- Default set of monitored resources -->  
    <WatchedResource>WEB-INF/web.xml</WatchedResource>  
  
    <!-- Uncomment this to disable session persistence across Tomcat restarts -->  
    <!--
    <Manager pathname="" />
    -->  
  
    <!-- Uncomment this to enable Comet connection tacking (provides events  
         on session expiration as well as webapp lifecycle) -->  
    <!--
    <Valve className="org.apache.catalina.valves.CometConnectionManagerValve" />
    -->  
  
  <Valve className="com.orangefunction.tomcat.redissessions.RedisSessionHandlerValve" />  
  <Manager className="com.orangefunction.tomcat.redissessions.RedisSessionManager"  
   host="10.10.49.20"  
   port="6379"  
   database="0"  
   maxInactiveInterval="60" />  
</Context>  


Put an index.jsp in tomcat/webapps/test

<%@ page language="java" %>  
<html>  
  <head><title>TomcatA</title></head>  
  <body>  
   
    <table align="centre" border="1">  
      <tr>  
        <td>Session ID</td>  
        <td><%= session.getId() %></td>  
      </tr>  
      <tr>  
        <td>Created on</td>  
        <td><%= session.getCreationTime() %></td>  
     </tr>  
    </table>  
  </body>  
</html>  
sessionID:<%=session.getId()%>   
<br>   
SessionIP:<%=request.getServerName()%>   
<br>   
SessionPort:<%=request.getServerPort()%>   
<%   
// To distinguish, the second can be 222  
out.println("This is Tomcat Server 1111");   
%>    


The access path is constantly refreshed, and it can be seen that although the server has changed from 1111 to 2222, the session creation time has not changed, which completes the session sharing.

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326798224&siteId=291194637