title: Failed to load resource: net::ERR_TOO_MANY_REDIRECTS
body: <p>I just started learning Backbone JS. In below code, iam just trying to call url <strong>todos/1</strong> expecting to get json data. Instead iam getting error in console as "<strong>Failed to load resource: net::ERR_TOO_MANY_REDIRECTS</strong>" I didnt understood why index.jsp keep redirecting many times itself.</p>
  
  <p><strong>Could anyone please explain me what went wrong and also solution too</strong></p>
  
  <p><strong>test.jsp</strong></p>
  
  <pre><code>&lt;html&gt;
  
  &lt;head&gt;
  
  &lt;script
      src="http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.1/jquery.min.js"&gt;&lt;/script&gt;
  &lt;script
      src="http://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.7.0/underscore-min.js"&gt;&lt;/script&gt;
  &lt;script
      src="http://cdnjs.cloudflare.com/ajax/libs/backbone.js/1.1.2/backbone-min.js"&gt;&lt;/script&gt;
  
  
  &lt;script type="text/javascript"&gt;
      var myname;
      var myjson;
  
      //WAY ONE
      $.getJSON("todos/1", alertUser);
  
      function alertUser(data) {
          console.log(data.id);
          id = data.id;
           alert(id);
  
          var TodoItem = Backbone.Model.extend({});
          var todoItem = new TodoItem(data);
  
          var TodoView = Backbone.View.extend({
              render: function(){
                  var html = '&lt;h3&gt;' + this.model.get('description') + '&lt;/h3&gt;';
                  $(this.el).html(html);
          }});
          var todoView = new TodoView({model : todoItem});
          todoView.render();
          console.log(todoView.el);
  
      }
  
  
  &lt;/script&gt;
  
  &lt;/head&gt;
  
  
  &lt;body&gt;
  
  &lt;/body&gt;
  
  
  &lt;/html&gt;
  </code></pre>
  
  <p><strong>index.jsp</strong></p>
  
  <pre><code>&lt;%@ page language="java" contentType="text/html; charset=UTF-8"
      pageEncoding="UTF-8"%&gt;
     &lt;%@page import="org.json.JSONObject" %&gt; 
  
  
  &lt;%
  
  JSONObject obj = new JSONObject();
  
  obj.put("description", "pick up milk");
  obj.put("status", "incomplete");
  obj.put("id", 1);
  
  response.setContentType("application/json");
  
  out.print(obj);
  %&gt;
  </code></pre>
  
  <p><strong>MyServlet.java</strong></p>
  
  <pre><code>public class MyServlet extends HttpServlet {
      private static final long serialVersionUID = 1L;
  
      /**
       * Default constructor. 
       */
      public MyServlet() {
          // TODO Auto-generated constructor stub
      }
  
      /**
       * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
       */
      protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
          response.sendRedirect("index.jsp");
      }
  
  
  }
  </code></pre>
  
  <p><strong>web.xml</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;web-app xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"&gt;
    &lt;servlet&gt;
      &lt;servlet-name&gt;MyServlet&lt;/servlet-name&gt;
      &lt;servlet-class&gt;MyServlet&lt;/servlet-class&gt;
    &lt;/servlet&gt;
    &lt;servlet-mapping&gt;
      &lt;servlet-name&gt;MyServlet&lt;/servlet-name&gt;
      &lt;url-pattern&gt;/todos/*&lt;/url-pattern&gt;
    &lt;/servlet-mapping&gt;
  &lt;/web-app&gt;
  </code></pre>