aspose file tools*
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
Author

How to make the URL without the "webapp"

Kevin Kan
Greenhorn

Joined: Jun 14, 2011
Posts: 2
Hi,

I have integrated Apache2 with Tomcat7. I have also deployed my webapp "app1" in the "webapps" folder. I can access my "app1" successfully at http://app1.domain.com/app1/index.jsp.

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 http://app1.domain.com/app1/index.jsp. How can I access the application at http://app1.domain.com/index.jsp?

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

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

Bill
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16065
    
  21

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 "app1.domain.com" 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".


Customer surveys are for companies who didn't pay proper attention to begin with.
Kevin Kan
Greenhorn

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!

Cheers!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to make the URL without the "webapp"