Name
<ora:addCookie>
Synopsis
The <ora:addCookie>
action sets response headers for creating or
deleting a cookie. It must be used
before the response is committed, for instance before a
<jsp:include>
action with the
flush
attribute set to true
.
Syntax
<ora:addCookie name="cookieName
" value="cookieValue
" [maxAge="ageInSeconds
"] />
Attributes
Attribute name |
Java type |
Dynamic value accepted |
Description |
---|---|---|---|
name |
String |
EL expression |
The cookie name. |
value |
String |
EL expression |
The cookie value. |
maxAge |
String |
EL expression |
The number of seconds before the cookie expires. Default is -1, meaning that the cookie expires when the browser is closed. Use 0 to delete the cookie from the browser. |
Example
<%-- Add a cookie named "userName", using the value from a request parameter with the same name, that expires in 30 days --%> <ora:addCookie name="userName" value="${param:username}" maxAge="${30 * 24 * 60 * 60}" /> <%-- Delete a cookie named "userName" --%> <ora:addCookie name="userName" value="ignored" maxAge="0" />
Get JavaServer Pages, Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.