title: How to mention URL while submitting ajax form?
body: <p>I am using HTML/JQuery/AJax to call a servlet. I am submitting a form to servlet. But it always gives 404 saying resource not found. i have maven project.</p>
  
  <p>I have Servlet in <code>src/main/java</code> package is : <code>com.mycompany.sample</code></p>
  
  <p>I have jsp in <code>webapp/public</code> folder.</p>
  
  <p>in web.xml i registered servlet using url pattern <code>/myController</code></p>
  
  <p>in jsp i gave action to my form as below:</p>
  
  <pre><code>&lt;form action="myController" ...............
  </code></pre>
  
  <p>and i have a separate .js file where i mentioned ajax call as below"</p>
  
  <pre><code> $.ajax({
          type: "POST",
          url: "myController",
          data: dataString,
          success: function(msg) {
              alert('success');
          },
          error: function(ob,errStr) {
              alert('onfailure');
          }
      });
  </code></pre>
  
  <p>But i always get 404 error saying <code>/myController</code> resource is not found and i get <code>onfailure</code> alert.</p>
  
  <p>Am i giving correct reference to <code>myController</code> in my <code>form</code> and in <code>ajax</code> call?</p>
  
  <p>Thanks!</p>