Note that there are some explanatory texts on larger screens.

plurals
  1. POCall POST data from one servlet to another server
    primarykey
    data
    text
    <p>I am submitting JSON data from my GWT-Client and Passing it to my GWT-Server. And i want to re-submit data to another server and want response from another server to GWT-Client.</p> <p>I just don't know how can i do this. I tried below code but not working.</p> <p>My Code is :</p> <pre><code>@Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { System.out.println("POST"); StringBuffer jb = new StringBuffer(); URL oracle = new URL("http://www.google.com"); HttpURLConnection connection = null; connection = (HttpURLConnection) oracle.openConnection(); connection.setRequestMethod("GET"); connection.setDoOutput(true); connection.setDoInput(true); request.getInputStream(); OutputStream wr = connection.getOutputStream(); InputStream in = request.getInputStream(); byte[] buffer = new byte[512]; int read = in.read(buffer, 0, buffer.length); while (read &gt;= 0) { wr.write(buffer, 0, read); read = in.read(buffer, 0, buffer.length); } wr.flush(); wr.close(); BufferedReader in1 = new BufferedReader(new InputStreamReader( connection.getInputStream())); String inputLine; while ((inputLine = in1.readLine()) != null) { jb.append(inputLine); } response.setContentType("text/html"); // Get the printwriter object from response to write the required json // object to the output stream PrintWriter out = response.getWriter(); // Assuming your json object is **jsonObject**, perform the following, // it will return your json object out.print(jb.toString()); out.flush(); in1.close(); } </code></pre> <p>Please help me.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload