title: jQuery not executing servlet doGet
body: <p>I am fairly new to java and am trying to get the solution posted here working: <a href="https://stackoverflow.com/q/4112686/1065197">How to use Servlets and Ajax?</a>, but the jQuery call is not executing the servlet.  </p>
  
  <p>Servlet code is as follows:</p>
  
  <pre><code>package com.morley.app;
  
  import java.io.IOException;
  import java.io.PrintWriter;
  
  import javax.servlet.ServletException;
  import javax.servlet.http.HttpServlet;
  import javax.servlet.http.HttpServletRequest;
  import javax.servlet.http.HttpServletResponse;
  
  public class AjaxTest extends HttpServlet {
  
  @Override
  protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
      String text = "some text";
      System.out.println("Im working");
      response.setContentType("text/plain");  // Set content type of the response so that jQuery knows what it can expect.
      response.setCharacterEncoding("UTF-8"); // You want world domination, huh?
      response.getWriter().write(text);       // Write response body.
  }
  }
  </code></pre>
  
  <p>My web.xml mappings are as follows:</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;servlet&gt;    
      &lt;servlet-name&gt;AjaxTest&lt;/servlet-name&gt;
      &lt;servlet-class&gt;com.test.app.AjaxTest&lt;/servlet-class&gt;
  &lt;/servlet&gt;
  &lt;servlet-mapping&gt;
      &lt;servlet-name&gt;AjaxTest&lt;/servlet-name&gt;
      &lt;url-pattern&gt;/AjaxTest&lt;/url-pattern&gt;
  &lt;/servlet-mapping&gt;
  </code></pre>
  
  <p>And my jsp is as follows:</p>
  
  <pre class="lang-html prettyprint-override"><code>&lt;head&gt;
      &lt;title&gt;SO question 4112686&lt;/title&gt;
  
      &lt;script type="text/javascript" src="&lt;%= request.getContextPath() %&gt;/js/jquery-latest.min.js"&gt;&lt;/script&gt;
  
      &lt;script&gt;
          $(document).ready(function() {                        // When the HTML DOM is ready loading, then execute the following function...
  
              $('#somebutton').click(function() {               // Locate HTML DOM element with ID "somebutton" and assign the following function to its "click" event...
  
                  $.get('AjaxTest', function(responseText) { // Execute Ajax GET request on URL of "someservlet" and execute the following function with Ajax response text...
                      //alert('ready');
                      $('#somediv').text(responseText);         // Locate HTML DOM element with ID "somediv" and set its text content with the response text.
                  });
  
              });    
          });
      &lt;/script&gt;
  
  &lt;/head&gt;
  &lt;body&gt;
      &lt;button id="somebutton"&gt;press here&lt;/button&gt;
      &lt;div id="somediv"&gt;&lt;/div&gt;
  &lt;/body&gt;
  </code></pre>
  
  <p></p>
  
  <p>If anyone can help me figure out why the doGet isn't firing it would greatly appreciated</p>