1 Reply Latest reply: Feb 27, 2012 10:47 PM by Steve Button-Oracle RSS

    REST POST REQUEST IN JSP

    Claudio A.
      Hi to all ....

      A need to create a Jsp page that make a REST POST request to a server .....

      I need to send this in the call

      {

      "context":{

      "banca":"3500",

      "identity":

      {

      "userID":"dmadmin",

      "repository":"rep01"

      }

      },

      "documentType":"ESTIM00029_000",

      "naturalKeys":

      [

      {"key":"progressivo", "value":"1"}

      ]

      }


      Any source exaple ???

      Thank's in advance
        • 1. Re: REST POST REQUEST IN JSP
          Steve Button-Oracle
          This is not really a JSP question, but moreover a HTML and JavaScript question.

          Here's a description and a worked example of using the low level XmlHttpRequest Object to issue a POST request:

          http://www.w3schools.com/ajax/ajax_xmlhttprequest_send.asp
          xmlhttp.open("POST","ajax_test.asp",true);
          xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
          xmlhttp.send("fname=Henry&lname=Ford");
          In which case, you'd want to specify the application/json content type and send your data in JSON form as a parameter of the send call.

          http://www.w3schools.com/ajax/tryit.asp?filename=tryajax_post

          Or you could choose to look at some the brilliant JavaScript frameworks that exist such as JQuery, Prototype, Dojo, etc. and make use of their higher level API to do this sort of thing.

          Here's the documentation for the JQuery.post function:

          http://api.jquery.com/jQuery.post/

          -steve-