Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Quickly output Session ID within a .JSP?

Tags:

jsp

jakarta-ee

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}"/>
like image 569
AndreiM Avatar asked Mar 11 '09 15:03

AndreiM


People also ask

What is session Getattribute in JSP?

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.

Which object is used in session tracking in JSP?

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.

How are cookies used for session tracking in JSP?

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.


1 Answers

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() %>

like image 96
evnafets Avatar answered Oct 04 '22 13:10

evnafets