Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Tomcat7 cooperates with redis to realize session sharing

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/03 Report--

1. To install redis, it is relatively easy to check out the following blog

two。 Configure two Tomcat on this machine, which are tomcat7-8081 and tomcat7-8082.

Compile two index.jsp pages and put them in the tomcat7-8081\ webapps\ ROOT and tomcat7-8082\ webapps\ ROOT directories respectively. The contents of the index.jsp pages are as follows:

Get session id

Session Id:

#

Tomcat7-8081 access address: http://localhost:8081, browse display content: Session Id: ABA0CD68C927D855BD42A306AB17790C

Tomcat7-8082 access address: http://localhost:8082, browse display content: Session Id: A86BC413D12339380DD7B0079C50D9EB

Note: configure multiple Tomcat tutorials on the same server

3. Copy the jar required by tomcat

Copy the following jar to ${TOMCAT_HOME} / lib

Tomcat-redis-session-manager-VERSION.jar jedis-2.5.2.jar commons-pool2-2.2.jar

4. Configure tomcat

Edit ${TOMCAT_HOME} / conf/context.xml and add it to context

Where host and port are the ip and ports of redis

Now that the configuration is complete, tomcat uses redis to host session.

5. test

Note: tomcat needs to be restarted

Open the browser and enter http://localhost:8081 to enter.

Open the browser and enter http://localhost:8082 to enter.

The SESSIONID obtained is the same, which means it is successful, where ABA0CD68C927D855BD42A306AB17790C is SESSIONID.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report