title: Getting 415(Unsupported media type error) while sending the Json data from Jsp to Rest Controller
body: <p>I am trying send the Json Data from Jsp to Rest service contoller.Below is the Jsp code.</p>
  
  <pre><code>function send_data(){
   var pg_registration_id=document.getElementById("pg_registration_id").value;
   var mid=document.getElementById("mid").value;
   var tid=document.getElementById("tid").value;
   var request = {pg_registration_id,mid,tid};
  alert("Json Data "+JSON.stringify(request));
  
   jQuery.ajax({
       url: "/RESTfulExample/rest/makePayment",
       type: "POST",
       data: JSON.stringify(request),  
       dataType: "json",
       beforeSend: function(x) {
         if (x &amp;&amp; x.overrideMimeType) {
           x.overrideMimeType("application/j-son;charset=UTF-8");
         }
       },
       success: function(result) {   
       alert('Successs' +data);
       }    
  });
  }
  </code></pre>
  
  <p>Below is the Rest Service Controller which accept Post request from Jsp.</p>
  
  <pre><code>@Path("/")
  public class RequestHandler {
   @POST
      @Path("/makePayment")
      @Consumes({MediaType.APPLICATION_JSON})
      @Produces("application/json")
      public Response merchantAuthention(final MerchantPaymentDetail  request) { 
          MerchantPayment merchantPayment = new MerchantPayment();
          return merchantPayment.merchantPayment(request);
      }
  
  }
  </code></pre>
  
  <p>Below is Web.xml</p>
  
  <pre><code>&lt;web-app id="WebApp_ID" version="2.4"
  xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee 
  http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"&gt;
  &lt;display-name&gt;Restful Web Application&lt;/display-name&gt;
  
  &lt;servlet&gt;
      &lt;servlet-name&gt;jersey-serlvet&lt;/servlet-name&gt;
      &lt;servlet-class&gt;com.sun.jersey.spi.container.servlet.ServletContainer&lt;/servlet-class&gt;
      &lt;init-param&gt;
          &lt;param-name&gt;com.sun.jersey.config.property.packages&lt;/param-name&gt;
          &lt;param-value&gt;com.es.rest&lt;/param-value&gt;
      &lt;/init-param&gt;
      &lt;init-param&gt;
      &lt;param-name&gt;com.sun.jersey.api.json.POJOMappingFeature&lt;/param-name&gt;
      &lt;param-value&gt;true&lt;/param-value&gt;
  &lt;/init-param&gt;   
      &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;
  &lt;/servlet&gt;
  
  &lt;servlet-mapping&gt;
      &lt;servlet-name&gt;jersey-serlvet&lt;/servlet-name&gt;
      &lt;url-pattern&gt;/rest/*&lt;/url-pattern&gt;
  &lt;/servlet-mapping&gt;
  </code></pre>
  
  <p></p>
  
  <p>Below is Pom.xml</p>
  
  <p></p>
  
  <pre><code>&lt;dependency&gt;
      &lt;groupId&gt;org.codehaus.jackson&lt;/groupId&gt;
      &lt;artifactId&gt;jackson-mapper-asl&lt;/artifactId&gt;
      &lt;version&gt;1.9.7&lt;/version&gt;
  &lt;/dependency&gt;
  
  &lt;dependency&gt;
      &lt;groupId&gt;org.codehaus.jackson&lt;/groupId&gt;
      &lt;artifactId&gt;jackson-core-asl&lt;/artifactId&gt;
      &lt;version&gt;1.9.7&lt;/version&gt;
  &lt;/dependency&gt;
  
  
  
  &lt;!-- http://mvnrepository.com/artifact/org.json/json --&gt;
  &lt;dependency&gt;
      &lt;groupId&gt;org.json&lt;/groupId&gt;
      &lt;artifactId&gt;json&lt;/artifactId&gt;
      &lt;version&gt;20160212&lt;/version&gt;
  &lt;/dependency&gt;
  &lt;dependency&gt;
      &lt;groupId&gt;javax.servlet&lt;/groupId&gt;
      &lt;artifactId&gt;servlet-api&lt;/artifactId&gt;
      &lt;version&gt;2.5&lt;/version&gt;
  &lt;/dependency&gt;
  &lt;dependency&gt;
      &lt;groupId&gt;junit&lt;/groupId&gt;
      &lt;artifactId&gt;junit&lt;/artifactId&gt;
      &lt;version&gt;4.8.2&lt;/version&gt;
      &lt;scope&gt;test&lt;/scope&gt;
  &lt;/dependency&gt;
  
  &lt;dependency&gt;
      &lt;groupId&gt;com.sun.jersey&lt;/groupId&gt;
      &lt;artifactId&gt;jersey-server&lt;/artifactId&gt;
      &lt;version&gt;1.8&lt;/version&gt;
  &lt;/dependency&gt;
  &lt;dependency&gt;
      &lt;groupId&gt;com.sun.jersey&lt;/groupId&gt;
      &lt;artifactId&gt;jersey-json&lt;/artifactId&gt;
      &lt;version&gt;1.8&lt;/version&gt;
  &lt;/dependency&gt;
  
  &lt;dependency&gt;
      &lt;groupId&gt;mysql&lt;/groupId&gt;
      &lt;artifactId&gt;mysql-connector-java&lt;/artifactId&gt;
      &lt;version&gt;5.1.38&lt;/version&gt;
  &lt;/dependency&gt;
  &lt;dependency&gt;
      &lt;groupId&gt;org.hibernate&lt;/groupId&gt;
      &lt;artifactId&gt;hibernate-entitymanager&lt;/artifactId&gt;
      &lt;version&gt;4.1.4.Final&lt;/version&gt;
  &lt;/dependency&gt;
  
  &lt;dependency&gt;
      &lt;groupId&gt;org.hibernate.common&lt;/groupId&gt;
      &lt;artifactId&gt;hibernate-commons-annotations&lt;/artifactId&gt;
      &lt;version&gt;4.0.4.Final&lt;/version&gt;
  &lt;/dependency&gt;
  
  &lt;dependency&gt;
      &lt;groupId&gt;javax.servlet&lt;/groupId&gt;
      &lt;artifactId&gt;jstl&lt;/artifactId&gt;
      &lt;version&gt;1.2&lt;/version&gt;
  &lt;/dependency&gt;
  </code></pre>
  
  <p></p>
  
  <p>I inserted alert on Jsp page, alert shows the correct Json data format but while sending that Json format data to Rest Controller it shows 415.</p>
  
  <p>Am i missing something in dependencies or in Jsp code?</p>