Prev Question
Next Question

Which EL expression returns true if no session has been established with current client?

A.
${not(pageContext.session)}

B.
${not(requestScope.session)}

C.
${requestScope.sessions.this}

D.
${sessionScope.empty}

Explanation:
Note:
* A session is never null. The session is always present in JSP EL, unless you add
<%@page session=”false” %>
* If you’d like to check if the session is new or has already been created, use HttpSession#isNew() instead.
<c:if test=”${not pageContext.session[‘new’]}”>
<p>You’ve already visited this site before.</p>
</c:if>
<c:if test=”${pageContext.session[‘new’]}”>
<p>You’ve just started the session with this request!</p> </c:if>

Prev Question
Next Question

Leave a Reply

Your email address will not be published. Required fields are marked *