Below snippet is just for your reference. We can print a cookie value on JSP page using JSP Expression language.
The standard syntax to access Http Cookie value in JSP is:
Code language: JavaScript (javascript)${cookie.<cookie name>.value}
So if you want to print value of cookie named “foo” on JSP page, you might wanna write something like:
Code language: JavaScript (javascript)${cookie.foo.value}
In previous tutorial How to access Cookies in Spring MVC, I used JSP expression language to print value of hitCounter cookie.
In JSP expression language ${cookie}
gives a list of all cookies set for current webpage. This list can be iterated using JSTL <c:forEach>
to print each cookie. Here is a small JSTL code snippet that prints list of all cookies for current page.
<h3>List of all the available Cookies</h3>
<ul>
<c:forEach var="cookies" items="${cookie}">
<li>
<c:out value="${cookies.key}" />:
Object=
<c:out value="${cookies.value}" />,
value=
<c:out value="${cookies.value.value}" />
</li>
</c:forEach>
</ul>
Code language: HTML, XML (xml)
Once you run this code, you’ll see list of all http cookies for given page as below.
Hope you’ll remember this little trick next time you want something like this.
Java URL Encoder/Decoder Example - In this tutorial we will see how to URL encode/decode…
Show Multiple Examples in OpenAPI - OpenAPI (aka Swagger) Specifications has become a defecto standard…
Local WordPress using Docker - Running a local WordPress development environment is crucial for testing…
1. JWT Token Overview JSON Web Token (JWT) is an open standard defines a compact…
GraphQL Subscription provides a great way of building real-time API. In this tutorial we will…
1. Overview Spring Boot Webflux DynamoDB Integration tests - In this tutorial we will see…
View Comments
Its good thanks for sharing.. Good work keep up..
is there any shortcut keyword to generate to setters and getters in eclipse? Thank you in Advance.