问题
Hi i would like to know how i can display the current users username/name on a webpage when they have logged on... i am storing their username like this
request.getSession().setAttribute("currentUser", username);
and wat to display their username on the jsp(web page) like this
<p> welcome <% request.getSession().getAttribute("currentUser"); %></p>
however it doesn't work... any tips? or a method that works
回答1:
Try using an expression, instead of a scriptlet:
<%= request.getSession().getAttribute("currentUser"); %>
Your scriplet will execute, but nothing is output. The result of an expression is automtically written to the output.
来源:https://stackoverflow.com/questions/26692480/how-do-you-dispay-the-current-logged-in-user-in-jsp-java-servlets