title: Tomcat: Setting custom url of servlet (servlet-mapping vs .war-deployment)
body: <p>I hope someone can help me with this one. I am running a dummy-servlet on a Tomcat server. This works basically, website is reachable after start.
  I would like to specify a custom url e.g. <code>localhost:8080/mydesiredname</code></p>
  
  <p>I deploy my servlet as .war file. It turned out that the name of the .war determines the name of the url under which Tomcat is reachable. If its called <code>abc</code> my servlet will run under <code>localhost:8080/abc</code>.</p>
  
  <p>While I am not unhappy with this solution I wonder what is the <code>servlet-mapping</code> good for in the <code>&lt;Tomcathome&gt;/conf/web.xml</code>. I tried to override and/or add an additional url name under which my servlet should be reachable but this does not seem to work.
  My code in the web.xml looks like this:</p>
  
  <pre><code>&lt;servlet&gt;
    &lt;servlet-name&gt;ABC&lt;/servlet-name&gt;
    &lt;servlet-class&gt;myservlet.TheServlet&lt;/servlet-class&gt;
  &lt;/servlet&gt;
  
      &lt;servlet-mapping&gt;
    &lt;servlet-name&gt;ABC&lt;/servlet-name&gt;
    &lt;url-pattern&gt;/otherUrl&lt;/url-pattern&gt;
  &lt;/servlet-mapping&gt; 
  </code></pre>
  
  <p>So I would expect either that my servlet is only reachable by <code>/otherUrl</code> or additionally to the url decided by the .war name. I am probably missing something. Can some clarify this for me? </p>