Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>See the <a href="https://jersey.java.net/apidocs/latest/jersey/org/glassfish/jersey/server/ContainerRequest.html#setProperty%28java.lang.String,%20java.lang.Object%29" rel="nofollow"><code>ContainerRequest#setProperty(String, Object)</code></a> method which states</p> <blockquote> <p>In a Servlet container, the properties are synchronized with the ServletRequest and expose all the attributes available in the ServletRequest. Any modifications of the properties are also reflected in the set of properties of the associated ServletRequest.</p> </blockquote> <p>So you can simply call</p> <pre><code>final String xml = getRequestBody(containerRequest); containerRequest.setProperty("xml", xml); </code></pre> <p>then inject the <code>HttpServletRequest</code> in your handler and access it with <code>HttpServletRequest#getAttribute("xml")</code>.</p> <p><strong>With Jersey 1.17</strong>, the corresponding method is <a href="https://jersey.java.net/apidocs/1.17/jersey/com/sun/jersey/spi/container/ContainerRequest.html#getProperties%28%29" rel="nofollow"><code>ContainerRequest#getProperties()</code></a> which returns a mutable <code>Map&lt;String, Object&gt;</code> to which you can put attributes that will be synchronized with the <code>ServletRequest</code>.</p> <p>You can retrieve a property in your Jersey resource from <a href="https://jersey.java.net/apidocs/1.17/jersey/com/sun/jersey/api/core/HttpContext.html" rel="nofollow"><code>HttpContext</code></a>: </p> <pre><code>@Context private HttpContext httpCtx ... final String xml = httpCtx.getProperties().get("xml") </code></pre> <hr> <p>On a different note, careful consuming the request <code>InputStream</code>. If some other component in your stack needs to read from the stream as well, it will fail.</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. 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