Drive has 700+ articles for digital transformation leaders written by StarCIO Digital Trailblazer, Isaac Sacolick. Learn more.

In a previous post, I asked about setting up Tomcat with multiple root folders and a single application. Use this recipe if

  • you are deploying a single application as a .war file
  • you need multiple root folders for your application
  • you store data in HttpSession
  • you have the Apache WS with mod_rewrite enabled

Recipe

  1. Open your server.conf file in CATALINA_HOME/conf and add the following parameter to your Connector setting emptySessionPath=”true”. This setting will force Tomcat to use ‘/’ as the Cookie Path for JSESSIONID, the cookie used for sessions.
  2. Open your httpd.conf file. First, you’ll need to add additional proxy statements:

ProxyPass /newpath http://localhost:8080/applicationpath ProxyPassReverse /newpath http://localhost:8080/applicationpath

newpath is the new folder you want to setup.
applicationpath is the name of your war file

Note: I am assuming you’re running apache and Tomcat on the same server. If not, replace localhost with your Tomcat host.

3. Add the following rewrite rule to your httpd.conf file

RewriteRule ^/newpath/(.*) /applicationpath/$1

4. Write your URLs correctly using the /newpath

Why this works?

You’ve forced tomcat to set the Session’s cookie path to ‘/’, so no matter what directories you create, your application will still receive the session cookie. The proxy statement tells Apache about the new folder to map to your application. The rewrite rule makes tomcat think that the URI is for your application.

What else?

In my next report, I’ll tell you how to make sure your URLs are unique, something that is important for search engine optimization (SEO).

Published on:

Topics:

Leave a Reply


StarCIO

My company, StarCIO, provides leadership, learning, and advisory programs for companies looking to accelerate delivering business value from digital transformation. Contact me if you’d like to learn more about partnering opportunities.


Isaac Sacolick

Join us for a future session of Coffee with Digital Trailblazers, where we discuss topics for aspiring transformation leaders. If you enjoy my thought leadership, please sign up for the Driving Digital Newsletter and read all about my transformation stories in Digital Trailblazer.


Coffee with Digital Trailblazers hosted by Isaac Sacolick

Digital Trailblazers! Join us Fridays at 11am ET for a live audio discussion on digital transformation topics:  innovation, product management, agile, DevOps, data governance, and more!


Join the Community of StarCIO Digital Trailblazers

1 comment:

  1. Thanks for the emptySessionPath tip, exactly what I needed.

    For directory rewrites I always like to leave the trailing slash as part of the backreference, for example

    RewriteRule ^/newpath(/.*) /applicationpath$1

    That way both ‘newpath’ and ‘newpath/’ work.

About Drive

Drive Agility, Innovation, Transformation

Drive is the blog for digital transformation leaders brought to you by StarCIO and Isaac Sacolick.

Agility, Innovation, and Transformation are the three primary digital transformation core competencies that every StarCIO Digital Trailblazer must champion in their organizations. Learn more About Drive.


About the StarCIO Digital Trailblazer Community

StarCIO Digital Trailblazer Community

Revolutionizing traditional learning, networking, and advising experiences.

Visit the community


About StarCIO

StarCIO

About Isaac Sacolick

Isaac Sacolick

Author, 1,200+ articles, keynote speaker, Chief StarCIO Digital Trailblazer. Full bio


Driving Digital Newsletter

Driving Digital Newsletter

StarCIO Guides

StarCIO Agile Planning Guides

Digital Trailblazer

Digital Trailblazer by Isaac Sacolick

Driving Digital

Driving Digital by Isaac Sacolick

Driving Digital Standup

Driving Digital Standup

Coffee with Digital Trailblazers

StarCIO Coffee With Digital Trailblazers

Recognition

reworked imapct awards 2026 Judge
InfoWorld 2025 Judge
InfoWorld Technology of the Year 2024 Judge
Thinkers360 Top 10 in IT Leadership
Thinkers360 Top Agile Thought Leader
Thinkers360 Top DevOps Leader
Thinkers360 Top in Digital Transfomation
Thinkers360 Top in Analytics
Thinkers360 Top in Product Management

Discover more from StarCIO Digital Trailblazer Community

Subscribe now to keep reading and get access to the full archive.

Continue reading