title: keep getting error on AJAX request
body: <p>I'm working on a project whereby in a JSP page I make an AJAX GET request to URL:</p>
  
  <p><a href="http://[domain]/ChatEngine/ChatServlet/users/login?roomId=0&amp;name=Alan" rel="nofollow noreferrer">http://[domain]/ChatEngine/ChatServlet/users/login?roomId=0&amp;name=Alan</a></p>
  
  <p>This is pointing to a servlet I created named ChatServlet with my web.xml looking like this:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0"&gt;
  &lt;display-name&gt;ChatEngine&lt;/display-name&gt;
  &lt;servlet&gt; 
     &lt;servlet-name&gt;ChatEngine&lt;/servlet-name&gt; 
     &lt;servlet-class&gt;com.tacticalenterprisesltd.chat.servlets.ChatServlet&lt;/servlet-class&gt; 
  &lt;/servlet&gt;
  
  &lt;servlet-mapping&gt; 
   &lt;servlet-name&gt;ChatEngine&lt;/servlet-name&gt; 
   &lt;url-pattern&gt;/ChatServlet/*&lt;/url-pattern&gt; 
  &lt;/servlet-mapping&gt; 
  
  &lt;welcome-file-list&gt;
  &lt;welcome-file&gt;index.jsp&lt;/welcome-file&gt;    
  &lt;/welcome-file-list&gt;
  &lt;/web-app&gt;
  </code></pre>
  
  <p>My index.jsp jquery AJAX code looks like this:</p>
  
  <pre><code>    var chaturl = "http://[domain]/ChatEngine/ChatServlet";
      var dataString = "roomId=" + roomID + "&amp;name=" + uname;     
      $.ajax({
        type: "GET",
        url: chaturl + "/users/login", 
        data: dataString,
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        cache: false,
        statusCode: {
            404: function() {
                console.log('404 Could not contact server.');
            },
            500: function() {
                console.log('500 A server-side error has occurred.');
            }
        },
        success: function(msg) {
            ...               
        },
        error: function(err) {
          alert('Login Error: ' + err.responseText + '  Status: ' + err.status + ' Response Status: ' + err.responseStatus); 
        }
      });
  </code></pre>
  
  <p>When I execute the AJAX request it keeps going immediately to the error property and I can't figure out why.</p>
  
  <p>Here's the firebug readout:
  <img src="https://i.stack.imgur.com/4vawy.jpg" alt="enter image description here">
  Notice how it says, "OPTIONS" instead of "GET".  I suspect that's a clue, but I don't understand why the browser is interpreting the request this way when I explicitly set the type attribute to "GET".</p>
  
  <p>In the servlet, I wrote some println statements, but they aren't even being printed to the Eclipse console, so I know the servlet isn't even being called.</p>
  
  <p>I know the URL is correct because I opened a new tab in FireFox, entered the URL into the address field, and immediately got a correct response from the servlet.  So there's something screwy with the AJAX code.  At this point I can't see the forest for the trees.</p>
  
  <p>Please advise.</p>
  
  <p>Alan</p>