print() causing problems with response.addCookie()

Simon Besenbäck simon.besenbaeck at gmail.com
Fri Dec 9 09:24:10 UTC 2022


Hello,

I discovered that when I am executing a print() before an
response.addCookie() the cookie is not committed to the browser.

However, if I am using out.print() or out.println() the problem does not
occur and the cookie gets sent to the browser.



My Professor suggested that print() might call a flush() which commits the
response object and thus prevents the later response object from being
committed.

https://docs.oracle.com/javaee/7/api/javax/servlet/ServletResponse.html#flushBuffer--


Best Regards

Simon
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/nashorn-dev/attachments/20221209/3b2f76e6/attachment.htm>


More information about the nashorn-dev mailing list