Often times, you want to make RESTful API consumers capable of filtering data what they need from a GET API, rather than forcing them to consume all the response data unnecessary. There are two ways to achieve this filtering : server side response filtering and client side response filtering. Server side response filtering, though useful, […]
In this example, we will learn to set cookies into HTTP responses sent by Jersey REST APIs. This example makes use of javax.ws.rs.core.Response for setting cookies into REST responses sent to REST clients. Set Cookie Syntax To set a cookie in REST API response, get the Response reference and use it’s cookie() method. Rest API […]
In this example, we will learn to set cookies into HTTP requests invoked by Jersey client. This example makes use of Invocation.Builder for setting cookies into outgoing REST calls. Set Cookie Example To set a cookie in REST API request, first get reference of Invocation.Builder from webTarget.request() method, and then use it’s methods. Rest API […]
By default, Jersey uses JUL for logging – and does not print request/response entity bodies in logs. To print entity content, you must create your own LoggingFiler, and register it in place of default org.glassfish.jersey.filter.LoggingFilter. In this example, I am creating one such basic CustomLoggingFilter which extends org.glassfish.jersey.filter.LoggingFilter and implements ContainerRequestFilter and ContainerResponseFilter interfaces so […]
Learn to use Jersey REST client authentication using HttpAuthenticationFeature, which can be used to access REST APIs behind authentication security.