开发者

Writing multiple cookies to Java HTTP Response (HttpSlingServletResponse) not working

开发者 https://www.devze.com 2023-03-13 19:57 出处:网络
I am trying to write multiple cookies to a SlingHttpServletResponse, however only the last cookie i write is visible in the browser.

I am trying to write multiple cookies to a SlingHttpServletResponse, however only the last cookie i write is visible in the browser.

Ex. response.addCookie(new Cookie("foo", "bar")); response.addCookie(new Cookie("lion", "bear")); response.addCookie(new Cookie("cat", "dog"));

When I look at the cookies on my browser, the only cookie i see is the开发者_运维问答: "cat", "dog" cookie If i switch the order, the last cookie is always the one that displays (so i dont think its something with a specific cookie).

The Java API indicates that you can call response.addCookie() any number of times to add any number of cookies.

Im not sure if this is a Sling specific issue (i dont think it would be) but it might be?


Looking at the code, I suspect this is an issue of the underlying servlet container used.

By default Sling uses the Jetty 6 Container contained in the Apache Felix Http Bundle.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号