jersey icon indicating copy to clipboard operation
jersey copied to clipboard

Setting cookies in ContainerResponseContext removes existing cookies in HttpServletResponse

Open jerseyrobot opened this issue 10 years ago • 4 comments

Looks like if cookie is added using ContainerResponseContext it removes all cookies already added directly HttpServletResponse.

If we create new session using HttpServletRequest.getSession(), it should add Set-Cookie header to HttpServletResponse, which it does. However I have a ContainerResponseFilter which may beed to add some cookies. If I add cookie using

containerResponseContext.getHeaders().add(HttpHeaders.SET_COOKIE, new NewCookie(...));

, the Set-Cookie header for session cookie in HttpServletResponse is never sent to client.

I'm not sure if that's the proper way add cookies in Jersey, but at least the behaviour seems a bit strange.

Affected Versions

[2.22.1]

jerseyrobot avatar Nov 26 '15 13:11 jerseyrobot

  • Issue Imported From: https://github.com/jersey/jersey/issues/3282
  • Original Issue Raised By:@glassfishrobot
  • Original Issue Assigned To: @mpotociar

jerseyrobot avatar Apr 20 '18 07:04 jerseyrobot

@glassfishrobot Commented Reported by kheleniu

jerseyrobot avatar Nov 26 '15 13:11 jerseyrobot

@glassfishrobot Commented This issue was imported from java.net JIRA JERSEY-3010

jerseyrobot avatar Apr 25 '17 05:04 jerseyrobot

Any update on this? It's something we run into every now and then and it's a bit of a pain to deal with.

dminkley avatar Apr 02 '25 14:04 dminkley