I have a jax-rs endpoint. In side the endpoint I need to remove or change the existing value of an existing cookie. below I have mentioned my code.
@GET
@Path("/")
@Produces("text/html")
public String logout(@Context HttpServletRequest request, @QueryParam("logoutNotification") String logoutNotification,
@QueryParam("id_token_hint") String id_token_hint,@CookieParam("statusCookie") javax.ws.rs.core.Cookie cookie) {
Response response=null;
if(logoutNotification.equals("T")) {
if (cookie != null) {
//update the value of the statusCookie cookie or remove the existing statusCookie cookie
}
}
Somebody please help me to implement this. Thanks.
you can try something like this.
first time check is cookie named
statusCookie
is exist if no it create a new cookie and set value tofirst
. whenstatusCookie
exist it also create a new cookie with same name and set value tosecond
which is actually overwrite existing cookie value. because of same name.