Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>First of all, your query string is invalid.</p> <pre><code>params = "?id=test&amp;data=testdata"; </code></pre> <p>It should have been</p> <pre><code>params = "id=test&amp;data=testdata"; </code></pre> <p>The <code>?</code> is only valid when you concatenate it to the request URL as a GET query string. You should not use it when you want to write it as POST request body.</p> <p>Said that, if this service is not supposed to return HTML (e.g. plaintext, JSON, XML, CSV, etc), then use a servlet. Here's an example which emits plaintext.</p> <pre><code>String id = request.getParameter("id"); String data = request.getParameter("data"); response.setContentType("text/plain"); response.setContentEncoding("UTF-8"); response.getWriter().write(id + "," + data); </code></pre> <p>If this service is supposed to return HTML, then use JSP. Change the URL to point to the JSP's one.</p> <pre><code>String url = "http://LOCALHOST:8080/services/getdata.jsp"; </code></pre> <p>And then add the following to the JSP template to print the request parameters.</p> <pre><code>${param.id} ${param.data} </code></pre> <p>Either way, you should be able to get the result (the response body) by reading the <code>URLConnection#getInputStream()</code>.</p> <h3>See also:</h3> <ul> <li><a href="https://stackoverflow.com/questions/2793150/how-to-use-java-net-urlconnection-to-fire-and-handle-http-requests">How to use <code>URLConnection</code> to fire and handle HTTP requests?</a></li> </ul> <hr> <p>Unrelated to the concrete problem, you are not taking character encoding carefully into account. I strongly recommend to do so. See also the above link for detailed examples.</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.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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