Cookies require modification of response headers.<br>As per definition of the servlet spec, you cannot modify response headers from within a servlet or JSP that is included with a request dispatcher (or after there have been already written some bytes to the output stream).<br>
<br>You can only modify response headers in the most top servlet / JSP or if the request is forwarded.<br><br>Regards,<br>Stephan<br><br><br><div class="gmail_quote">2010/2/10 Brett Sheeran <span dir="ltr"><<a href="mailto:brett.sheeran@gmail.com">brett.sheeran@gmail.com</a>></span><br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Hi,<br>
<br>
I find that code for setting cookies inside a page element does not succeed.<br>
<br>
Here is some simple code placed inside an element:<br>
-----<br>
Cookie cookie = new Cookie ("ELEMENT_COOKIE", "value1");<br>
cookie.setMaxAge(31536000);//secs in a year<br>
cookie.setPath("/");<br>
response.addCookie(cookie);<br>
-----<br>
There are no errors, but *definitely* no cookies either. I checked<br>
using both request.getCookies(); and the show cookies button in my<br>
Safari browser.<br>
<br>
However, the previous code *will* work if placed inside the template<br>
JSP that calls the page element.<br>
<br>
Furthermore, the Following code does not work in a page element either.<br>
CmsRequestUtil.setCookieValue(cms, "ELEMENT_COOKIE2", "value2");<br>
<br>
Any suggestions?<br>
<br>
Thank you.<br>
<br>
Regards Brett Sheeran<br>
<br>
_______________________________________________<br>
This mail is sent to you from the opencms-dev mailing list<br>
To change your list options, or to unsubscribe from the list, please visit<br>
<a href="http://lists.opencms.org/mailman/listinfo/opencms-dev" target="_blank">http://lists.opencms.org/mailman/listinfo/opencms-dev</a><br>
</blockquote></div><br>