title: Handle custom exceptions using JQuery .ajax()
body: <p>Here is what my controller method looks like:</p>
  
  <pre><code>@RequestMapping(value = "/com/uData.htm", method = RequestMethod.GET)
  public @ResponseBody String getData(HttpServletRequest request, 
        HttpServletResponse response, @RequestParam(value="sn", required=true) String sn, 
        @RequestParam(value="serv", required=true) String serv,
        @RequestParam(value="date", required=false) String date) throws IOException{
  try {
        Srring data =...;
        if(condition == false) {
           throw new IOException("my exception message");
      }
  ...
  ...
  
      } catch (IOException ie) {
          response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, ie.getMessage());
          response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
          response.getWriter().write(ie.getMessage());
          response.flushBuffer();
      }
  
    return data;
  }
  </code></pre>
  
  <p>And here is what my jQuery ajax looks like</p>
  
  <pre><code>$.ajax({
      cache: false,
      url: "/com/uData.htm",
      dataType: 'json',
      data: {"sn": sn, "serv": selServ},
      success: function(dt){
      result = dt;
    },
      error: function(jqXHR, textStatus, errorThrown) {
        if(jqXHR.responseText !== '') {
            alert(textStatus+": "+jqXHR.responseText);
      } else {
            alert(textStatus+": "+errorThrown);
         }  
       }
    });
  </code></pre>
  
  <p>The custom exception message that is returned is not alert in my jsp
  using the</p>
  
  <pre><code>alert(textStatus+": "+jqXHR.responseText);
  </code></pre>
  
  <p>How do I return the custom exception message ("my exception message") to the JSP?</p>