1.

How do you set cookies in the JSP?

Answer»

Setting cookies with JSP involves three steps −

  • Creating a Cookie object − You call the Cookie constructor with a cookie name and a cookie value, both of which are strings.

  • Setting the maximum age − You use setMaxAge to specify how long (in seconds) the cookie should be valid.

  • Sending the Cookie into the HTTP response headers − You use response.addCookie to add cookies in the HTTP response header



Discussion

No Comment Found