Tag: jersey

Serving Files using Jersey Web Service (JAX-RS)

There are a lot of tutorials out there explaining how to send binary data (i.e. application/octet-stream) as response for Jersey web services (Java JAX-RS). Two possible solutions are based on either returning a Response or StreamingObject containing the appropriate binary data stream. Below you find a simple example for both scenarios: Additional checks have been […]

Custom Response Types in Jersey SecurityContext

Sometimes you might need to return custom response types in your SecurityContext implementation when using Jersey RESTFul web services. Basically, there are two options available to do so: Use javax.ws.rs.core.Response and throw a WebApplicationException or write your own ExceptionMapper Throw WebApplicationException Custom ExceptionMapper The other (even nicer option) is to write your own ExceptionMapper: