title: Servlet returns "HTTP Status 404 The requested resource (/servlet) is not available"
body: <p>I have an HTML form in a JSP file in my <code>WebContent/jsps</code> folder. I have a servlet class <code>servlet.java</code> in my default package in <code>src</code> folder. In my <code>web.xml</code> it is mapped as <code>/servlet</code>.</p>
  <p>I have tried several URLs in <code>action</code> attribute of the HTML form:</p>
  <pre class="lang-html prettyprint-override"><code>&lt;form action=&quot;/servlet&quot;&gt;
  </code></pre>
  <pre class="lang-html prettyprint-override"><code>&lt;form action=&quot;/servlet.java&quot;&gt;
  </code></pre>
  <pre class="lang-html prettyprint-override"><code>&lt;form action=&quot;/src/servlet.java&quot;&gt;
  </code></pre>
  <pre class="lang-html prettyprint-override"><code>&lt;form action=&quot;../servlet.java&quot;&gt;
  </code></pre>
  <p>But none of those work. They all keep returning a HTTP 404 error like below in Tomcat 6/7/8:</p>
  <blockquote>
  <h3>HTTP Status 404 — /servlet</h3>
  <p><em>Description</em>: The requested resource (/servlet) is not available.</p>
  </blockquote>
  <p>Or as below in Tomcat 8.5/9:</p>
  <blockquote>
  <h3>HTTP Status 404 — Not Found</h3>
  <p><em>Message</em>: /servlet</p>
  <p><em>Description</em>: The origin server did not find a current representation for the target resource or is not willing to disclose that one exists</p>
  </blockquote>
  <p>Or as below in Tomcat 10:</p>
  <blockquote>
  <h3>HTTP Status 404 — Not Found</h3>
  <p><em>Type</em>: Status Report</p>
  <p><em>Message</em>: The requested resource (/servlet) is not available</p>
  <p><em>Description</em>: The origin server did not find a current representation for the target resource or is not willing to disclose that one exists</p>
  </blockquote>
  <p>Why is it not working?</p>