title: URL of invoked servlet (newbie)?
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/4764405/how-to-use-relative-paths-without-including-the-context-root-name">How to use relative paths without including the context root name?</a>  </p>
  </blockquote>
  
  
  
  <p>In my Tomcat webapps directory, I have a context, app, that contains in its WEB-INFO/classes directory a tree named test, with a bunch of class files under it. app also contains an html file whose purpose is to collect user input and then invoke one of the servlets in the classes/test directory to generate HTML output. The web.xml describing the servlet is as follows:</p>
  
  <pre><code>&lt;servlet&gt;
    &lt;servlet-name&gt;foo&lt;/servlet-name&gt;
    &lt;servlet-class&gt;test.DoIt&lt;/servlet-class&gt;
  &lt;/servlet&gt;
  
  &lt;servlet-mapping&gt;
    &lt;servlet-name&gt;foo&lt;/servlet-name&gt;
    &lt;url-pattern&gt;/doit&lt;/url-pattern&gt;
  &lt;/servlet-mapping&gt;
  </code></pre>
  
  <p>The body of the html file is</p>
  
  <pre><code>&lt;FORM ACTION="/app/doit"&gt;
    First Parameter: &lt;INPUT TYPE="TEXT" NAME="param1"&gt;
    &lt;CENTER&gt;&lt;INPUT TYPE="SUBMIT"&gt;&lt;/CENTER&gt;
  &lt;/FORM&gt;
  </code></pre>
  
  <p>This all works. But it seems somehow wrong to have to specify the name of the app in the form action of the html file. Is there a way to avoid this, or can someone explain to me why it makes sense that you should have to? Thanks.</p>