Unable to set cookie in response header (newcookie doesn't show in external browser) : Jersey jax-rs

Posted by Pankhuri on Stack Overflow See other posts from Stack Overflow or by Pankhuri
Published on 2010-04-02T07:33:52Z Indexed on 2010/04/02 7:43 UTC
Read the original article Hit count: 673

Filed under:
|
|
|
|

I am trying to set a session cookie from server side :

import javax.ws.rs.core.NewCookie; import javax.ws.rs.core.Response;

public class Login {

@POST @Produces("application/json") @Consumes("application/json") public Response login (String RequestPacket){ NewCookie cookie=null; CacheControl cc=new CacheControl(); cookie = LoginBO.validUser(RequestPacket); cc.setNoCache(true); if(cookie.getValue()!=null) return Response.ok("welcome "+cookie.getValue()).cookie(cookie).cacheControl(cc).build(); else return Response.status(404).entity("Invalid User").build(); } }

In eclipse browser: on the client side (using gxt for that) when I print header i get the Set-Cookie field. which is expected. But the browser is not storing the cookie.

in external browser: the header doesn't have any set-cookie field.

Should I use HTTPServletResponse? But shouldn't the javax.ws.rs.core.Response work as well?

© Stack Overflow or respective owner

Related posts about jersey

Related posts about jax-rs