• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

Removing the Context path from my URL

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Bartender
Posts: 4100
63
Hibernate Fedora Chrome
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 .
 
Bartender
Posts: 20828
125
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!