Oracle
1Z0-899 · Question #162
Which EL expression returns true if no session has been established with current client?
The correct answer is A. ${not(pageContext.session)}. 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…
EL
Question
Which EL expression returns true if no session has been established with current client?
Options
- A${not(pageContext.session)}
- B${not(requestScope.session)}
- C${requestScope.sessions.this}
- D${sessionScope.empty}
How the community answered
(38 responses)- A82% (31)
- B11% (4)
- C5% (2)
- D3% (1)
Explanation
- 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 test="${pageContext.session['new']}"> <p>You've just started the session with this request!</p> </c:if>
Topics
#EL expressions#pageContext#session check#empty operator
Community Discussion
No community discussion yet for this question.