Category: Jersey
Creating Custom JAX-RS MessageBodyReader
You can use a JAX-RS MessageBodyReader to deserialize an entity on the server or client. Jersey already provides default deserializers like json and xml. This is just a demonstration how you can build your...
Creating Custom JAX-RS MessageBodyWriter
A JAX-RS MessageBodyWriter is responsible for converting Java types to a stream. In this example we are creating a JAX-RS MessageBodyWriter that produces text/html. This class may be annotated using the @Produces annotation to...
JAX-RS ChunkedOutput and ChunkedInput Example
In Jersey you can use ChunkedOutput to send response to a client in chunks. By using a chunked output the jersey runtime is informed that the response will be chunked and that the processing...
Low Level Streaming with JAX-RS StreamingOutput
When working with large data or files, it is recommended to stream the output rather than loading the entire response into memory. This helps protect the servers resources and avoids getting out of memory...
JAX-RS Path Segments and Matrix Parameters
Matrix Parameters are different from Query Parameters. Query parameters are typically placed at the end of the URI using the ? character. Matrix Parameters can be placed in every URI segment using the ;...
JAX-RS @BeanParam Example
The @BeanParam annotation is added to the JAX-RS 2.0 specification. It allows you to inject a pojo whose property methods or fields are annotated with any of the injection parameters supported by JAX-RS. To...
JAX-RS @CookieParam CRUD Example
Cookies are used to set up a session between the client and server or to remember the identity and user preferences between requests. These cookie values are transmitted to and from the client and...
JAX-RS @FormParam Example
We can post an HTML form directly to our JAX-RS service, we can read the request bodies by mapping the fields using the @FormParam annotation. Lets show how this works by a simple example....
Get HTTP Header Parameter in JAX-RS
When you need to get HTTP Header parameters with JAX-RS, you have a couple of options. You can use the @HeaderParam annotation provided by JAX-RS, Inject the HttpHeaders directly or inject the HttpServletRequest. Let’s...