File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Tomcat and the fly likes How to make the URL without the Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Tomcat
Bookmark "How to make the URL without the "webapp"" Watch "How to make the URL without the "webapp"" New topic

How to make the URL without the "webapp"

Kevin Kan

Joined: Jun 14, 2011
Posts: 2

I have integrated Apache2 with Tomcat7. I have also deployed my webapp "app1" in the "webapps" folder. I can access my "app1" successfully at

However, I am wondering how can I further achieve the same without including the in the URL?
Ie. Currently I am accessing the application at How can I access the application at

Thanks in advance!
William Brogden
Author and all-around good cowpoke

Joined: Mar 22, 2000
Posts: 13037
Tomcat convention uses the app residing in the ROOT directory for that URL - just replace the contents of ROOT with your app.

Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 17417

EVERY Tomcat webapp has a "webapp" component to its URL. Or "context", as it's properly known. That's because Tomcat is a multi-application container, and the context servers as an indicator to Tomcat as to which of the applications it contains a given URL should be routed to. Context paths are simply 0 or more "directory levels" in the URL.

As William has said, there's a special context whose path is "/", meaning no levels at all and that's the root context. It's a little bit trickier to deploy than the others, since Tomcat is shipped with a root context already installed, so you have to replace it with your own app.

However, when you're fronting Tomcat with Apache, this isn't really necessary. You can use a "normal" context path in Tomcat and let Apache handle the difference. Typically, you'd define an Apache Virtual Host such as "" and within the virtual host definition you'd provide the connector to Tomcat for that virtual host using either the traditional connector or a mod_proxy connector. Part of that connector's definition would include the actual Tomcat context path in the translated URL, so that the user could use the simpler URL but Apache would route it to the proper context.

Here's an example of how it works using mod_proxy and a deployed webapp under the context name "WMS-tomcat".

An IDE is no substitute for an Intelligent Developer.
Kevin Kan

Joined: Jun 14, 2011
Posts: 2
Hi guys,

Thanks for your replies.

To William:
I've tried replacing the default 'ROOT' folder with my 'app1' folder and it worked like a charm!

To Tim:
I have mod_jk installed and was trying out your "proxy method" and is trying to confirm the changes required.
Below is my virtual host configuration for my subdomain:

Is this what you meant to reconfigure in Apache, in order to achieve the same result?
Thanks in advance!

I agree. Here's the link:
subject: How to make the URL without the "webapp"
It's not a secret anymore!