Print session attributes in jsp
java, jsp, servlets, spring
Solution
You can use EL, which is prefered in JSP.
<c:out value="${sessionScope.name}"/>
Or if the `name` value is HTML safe, you can use
${sessionScope.name}
Make sure the JSP is allow access session.
<%@ page session="true" %>
To use core JSTL, make sure the following code is included.
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
Problem
My webapp is ready but I just wanted to add a little dropdown menu with the username as title. This is my jsp code: ``` <i class="icon-user"></i> <% session.getAttribute("name"); %> <span class="caret"></span> ``` and it sais session cannot be resolved ``` 9: <a class="btn dropdown-toggle" data-toggle="dropdown" href="#"> 10: <i class="icon-user"></i> 11: <% 12: session.getAttribute("name"); 13: %> 14: <span class="caret"></span> 15: </a> ``` There is a session because I'm logged in. Kind regards,