aspose file tools*
The moose likes Tomcat and the fly likes Removing the Context path from my URL Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Removing the Context path from my URL" Watch "Removing the Context path from my URL" New topic
Author

Removing the Context path from my URL

mkv kk
Greenhorn

Joined: Jun 21, 2011
Posts: 1
Hi Guies,

I have registeread a domain and trying to deploy a war file in to the Appache tomcat server. Suppose
if my war file name is "foobar.war" then while deploying it will create a folder called "foobar", all my
web project structure under that only.So to access the domain I should have include the the directory
"foobar" also in to my URL(Ex: http://foobar.com/foobar/admin/sample.jsp) & It is irritating me.

So my expectation is I can access the domain like http://foobar.com/admin/sample.jsp.The tomcat server
I am using is a shared server.I know that some solution is there to resolve this issue.

I Have Read the Post "http://www.coderanch.com/t/541732/Tomcat/make-URL-without-webapp",But it will not help me because mine is a shared server and I havnt root access on that.



Can anybody please Help me to resolve this.

Thanks & Regards
Vivek
Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3825

Welcome to the Ranch!

So to access the domain I should have include the the directory "foobar" also in to my URL

That's only the first time if you try to access the site/application right? That's how it works since Tomcat is a container for multiple applications there should be a way to identify each. You also have the opportunity to use the "ROOT" context as you are already aware of. Other than that I don't think there's any other option rather than have a customized Tomcat server built in for this requirement .


SCJP 5 | SCWCD 5
[How to ask questions] [Twitter]
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16012
    
  19

First of all, it's not a "directory" name, it's a context name. As Vijatha has noted, Tomcat can host multiple applications at one time, and the context part of the URL indicates which application gets to process the URL request. The fact that Tomcat will by default take a war file and explode it into a directory with the same name as the WAR under the TOMCAT_HOME/webapps directory is purely an implementation detail not actually covered by the J2EE spec.

If you want an application to be at the root of a URL without a context name, you have to define it as the sole application within a virtual host. Tomcat allows setting up multiple virtual hosts, but it's not a minor task and from the sound of it, you don't have the rights to make the needed Tomcat configuration modifications in server.xml

More often, people front Tomcat with the Apache httpd server (or something like IIS) and set up a virtual host there that pipelines requests to the desired Tomcat URL context.


Customer surveys are for companies who didn't pay proper attention to begin with.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Removing the Context path from my URL