This week's book giveaway is in the Design forum.
We're giving away four copies of Building Microservices and have Sam Newman on-line!
See this thread for details.
The moose likes Tomcat and the fly likes Deploying a web-application within an application Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Building Microservices this week in the Design forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Deploying a web-application within an application" Watch "Deploying a web-application within an application" New topic

Deploying a web-application within an application

Dhaval J. Patel
Ranch Hand

Joined: Mar 10, 2011
Posts: 90

Hello everyone..
I have a web application that is running .. lets say the url is . I have a saperately developed web app that I would like to deploy at the location
How can I do this ?? Can I put the war file of the new application in the lib folder of the existing application and configure the web.xml to call that web application for that url pattern ?? I am not sure .. Just speculating ..
Please help

Thanks in advance
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 17044

No, you cannot place a WAR within a WAR. Each WAR is a stand-alone entity and its structure is defined by the J2EE spec - which among other things says that certain files and directories must be located at certain absolute places within the WAR file. Exploding the WAR file into a physical disk directory tree doesn't change that.

But what you really want is to provide 2 different contexts, where one context path is and extended version of the other context path. Since each context can locate its WAR anywhere it wants, actual physical embedding of a WAR isn't required.

The real question is "can Tomcat be directed to match first against a longer context path, then fall back to a shorter path if the longer match fails?". I don't know. It might even do that by default, although I'd have to RTFM, or maybe even the source code.

Assuming it doesn't, however, an alternative would be to employ a URL rewriting scheme so that, for example remaps to and (without the "/test") passes through unchanged.

An IDE is no substitute for an Intelligent Developer.
Dhaval J. Patel
Ranch Hand

Joined: Mar 10, 2011
Posts: 90

Thanks for the reply,
I'd go with the URL rewriting method. Should work fine
Have you checked out Aspose?
subject: Deploying a web-application within an application
It's not a secret anymore!