HeaderParam Annotation In Jersey

How to Get Value From Header in Jersey

If we want to send any information in header request then we get value of header by using HeaderParam annotation.There is a example how to use @HeaderParam Annotation in jesery

import javax.ws.rs.HeaderParam;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.Response.Status;

@Path(“/user”)
public class UserHander {

@POST
public Response addUser(@HeaderParam(“token”) String token) {
System.out.println(“token=” + token);
return Response.status(Status.OK).entity(token).build();
}

}

Leave a Reply

Your email address will not be published. Required fields are marked *

1 + 5 =