Reputation: 1694
This is code in servlet:
HttpSession session = request.getSession(true);
session.setAttribute("user", user);
I am forwarding request to JSP, where i want to check if there is session scoped user parameter attached.
<c:if test="${??? - check if user is attached to request}">
/ /message
</c:if>
Upvotes: 24
Views: 44100
Reputation: 119
I think you mean checking the session scope right?
<c:if test="${!empty sessionScope.user}">
Upvotes: 10
Reputation: 20741
you can do that by using the following code
Setting session in Servlet
HttpSession session = request.getSession();
session.setAttribute("user", user);
Access session value by EL
in JSP
<p>${sessionScope:user}</p>
Checking the session in JSP
using JSTL
<c:if test="${sessionScope:user != null}" >
session value present......
</c:if>
Upvotes: 1
Reputation: 691635
<c:if test="${sessionScope.user != null}">
There is a user **attribute** in the session
</c:if>
Upvotes: 37