blogger templates blogger widgets
This is part of a list of blog posts.
To browse the contents go to

JAX-RS: Sending/Receiving cookies

Server code,
public class HelloResource {
    public Response helloGet("username") String username) {
      return Response.ok("[GET] Hello "+username+" from JAX-RS on WebSphere Application server")
                 .cookie(new NewCookie("key","value"))

Client code,
String lsUrl = "http://localhost:9080/RSServer/HelloApp/hello";
RestClient client = new RestClient();
Resource resource = client.resource(lsUrl);
ClientResponse result = resource.contentType(MediaType.TEXT_PLAIN).cookie(new Cookie("username", "John")).get();

To obtain a general map of parameter names and values for query and path parameters, use the following code:
public String get(@Context UriInfo ui) {
    MultivaluedMap<String, String> queryParams = ui.getQueryParameters();
    MultivaluedMap<String, String> pathParams = ui.getPathParameters();

No comments:

Post a Comment