Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>For Jersey client, you can create a Jersey <a href="https://jersey.java.net/apidocs/1.17/jersey/com/sun/jersey/api/client/Client.html" rel="nofollow">Client</a> instance to post your JSON to the server. So in order to send in JSON format, you can use <a href="http://jackson.codehaus.org/" rel="nofollow">Jackson JSON library</a> and it can be bundled with Jersey by adding Jersey-JSON jars. You also need to add Jersey client dependency.</p> <pre><code> &lt;dependency&gt; &lt;groupId&gt;com.sun.jersey&lt;/groupId&gt; &lt;artifactId&gt;jersey-json&lt;/artifactId&gt; &lt;version&gt;1.17&lt;/version&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;com.sun.jersey&lt;/groupId&gt; &lt;artifactId&gt;jersey-client&lt;/artifactId&gt; &lt;version&gt;1.17&lt;/version&gt; &lt;/dependency&gt; </code></pre> <p>Then your client code will look like:</p> <pre><code>public String requestResource(String baseURL, String path) { Client wsClient = Client.create(); WebResource rs = wsClient.resource(baseURL); String response = rs.path(path).type(MediaType.APPLICATION_JSON).post(String.class, item); return response; } </code></pre> <p>Note that <code>MediaType.APPLICATION_JSON</code> in the <code>type</code> method specifies the data format. Here <code>item</code> contains the data you want to send to the server. Also, don't forget to put the following line in the <code>web.xml</code> so that all POJO classes will be automatically serialized to JSON.</p> <pre><code> &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; </code></pre>
    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.
 

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