How do I set a cookie within a JSP page?

Govind Seshadri

Setting cookies from within a JSP page is similar to the way they are done within servlets. For example, the following scriptlet sets a cookie "mycookie" at the client:

       Cookie mycookie = new Cookie("aName","aValue");

Typically, cookies are set at the beginning of a JSP page, as they are sent out as part of the HTTP headers.

0 Comments  (click to add your comment)
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.