DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones AWS Cloud
by AWS Developer Relations
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones
AWS Cloud
by AWS Developer Relations
Securing Your Software Supply Chain with JFrog and Azure
Register Today

Trending

  • Never Use Credentials in a CI/CD Pipeline Again
  • Future of Software Development: Generative AI Augmenting Roles and Unlocking Co-Innovation
  • IDE Changing as Fast as Cloud Native
  • Understanding the Role of ERP Systems in Modern Software Development

Trending

  • Never Use Credentials in a CI/CD Pipeline Again
  • Future of Software Development: Generative AI Augmenting Roles and Unlocking Co-Innovation
  • IDE Changing as Fast as Cloud Native
  • Understanding the Role of ERP Systems in Modern Software Development
  1. DZone
  2. Coding
  3. Languages
  4. Setup Redis as the Session Store for Apache Tomcat 7

Setup Redis as the Session Store for Apache Tomcat 7

Shiv Kumar Ganesh user avatar by
Shiv Kumar Ganesh
·
Aug. 16, 13 · Interview
Like (0)
Save
Tweet
Share
36.28K Views

Join the DZone community and get the full member experience.

Join For Free

Setting up the Redis Server as a session is really advantageous. First, its a NO-SQL database and second its really easy to scale using this. This kind of setup would lead to a clear understanding of how Redis can behave as cache as well as a session storing system. In order to do this the instructions are as follows :-

  1. Download Redis and build by the following commands (This includes downloading it too)
    wget http://download.redis.io/redis-stable.tar.gz tar xvzf redis-stable.tar.gz
    cd redis-stable
    make
  2. Start Redis using command(Redis Directory refers to the directory where Redis is built)
    cd RedisDirectory/src
    ./redis-server --port 6379
  3. Get the latest version of Apache Tomcat 7
  4. Download the latest version for JEDIS (A Redis Java Client), Tomcat Redis Session Manager (Redis-backed non-sticky session store for Apache Tomcat) and Apache Commons Pool .
  5. Copy all the above files into the lib folder of the Apache Tomcat 7 installation directory.
  6. Add the lines mentioned below in the context.xml of your Apache Tomcat 7 (Or on the context block of server.xml if applicable).Edit the Configurations as your settings. In out case the port number to be configured is 6279.
    <Valve className="com.radiadesign.catalina.session.RedisSessionHandlerValve" />
    <Manager className="com.radiadesign.catalina.session.RedisSessionManager"
    host="localhost" <!-- optional: defaults to "localhost" -->
    port="6379" <!-- optional: defaults to "6379" -->
    database="0" <!-- optional: defaults to "0" -->
    maxInactiveInterval="60" <!-- optional: defaults to "60" (in seconds) --> />
  7. Now restart your Apache Tomcat 7 normally and now you would see that the sessions are being created in the Redis Rather than on Tomcat.

Thats it. Now you have your Apache Tomcat 7 storing all the sessions in Redis and it also takes care about the different aspects of sessions.

Image: Courtesy – “Redis”
Thanks to the plugin creator James Coleman. You can find him on Git.
Article can be viewed on my blog at 
Shiv Ganesh .  

Apache Tomcat Redis (company) Session (web analytics)

Published at DZone with permission of Shiv Kumar Ganesh. See the original article here.

Opinions expressed by DZone contributors are their own.

Trending

  • Never Use Credentials in a CI/CD Pipeline Again
  • Future of Software Development: Generative AI Augmenting Roles and Unlocking Co-Innovation
  • IDE Changing as Fast as Cloud Native
  • Understanding the Role of ERP Systems in Modern Software Development

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com

Let's be friends: