Currently if i deploy a war file on tomcat named say myapp.war, I can access its url by http://localhost/myapp/MyServlet.
However what I want is to depl
I found all the advice on this subject somewhat terse and confusing. The below method works for me using a default tomcatee installation.
Suppose I have a war file named mywar.war. This holds a servlet mapping to '/hello'. I want to access this servlet from a url like localhost:8080/myapp/hello
This method avoids any changes to server.xml which is not advised as this requires tomcat restarts.
This method will fail is you deploy to /webapps as it will try and deploy the same war twice. Therefore I start by creating a new directory to deploy into. I use /apps but the dir name is arbitrary.
I now copy mywar.war into apps. Tomcat ignores this action. I now create a simple deployment file named myapp.xml. Note that the name of this file defines the URL context the war will be deployed under. I believe you can use ROOT.xml to deploy under . The contents are as follows:
As described this needs to be copied into /conf/Catalina/localhost This causes tomcat to expand and deploy the /apps/mywar.war and set the correct URL context. The servlet is now available on localhost://myapp/hello (or :8080//myapp/hello from a remote client).
Note that for a relative address the docBase URL identifies the location of the war from the webapps directory - hence the leading ..