I would like to quickly output the current session id on a .jsp page for debugging purposes.
Is this possible? Does anyone have a JSP snippet that does this?
Thanks very much!
Edit: I found what I was looking for:
<c:out value="${pageContext.session.id}"/>
The session attribute indicates whether or not the JSP page uses HTTP sessions. A value of true means that the JSP page has access to a builtin session object and a value of false means that the JSP page cannot access the builtin session object.
The session Object This interface provides a way to identify a user across. The JSP engine exposes the HttpSession object to the JSP author through the implicit session object.
Cookies mostly used for session tracking. Cookie is a key value pair of information, sent by the server to the browser. This should be saved by the browser in its space in the client computer. Whenever the browser sends a request to that server it sends the cookie along with it.
If you have EL enabled in your container, you can do it without the JSTL tag - ie just ${pageContext.session.id}
An alternative for containers without EL: <%= session.getId() %>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With