In my Dynamic Web Application (working in Eclipse, with Tomcat 7 server), my pages have the same header, which includes the username of the currently logged in user.
Rather than having the header appear identically on each page, I extracted and included
<%@ include file="../includes/head.jsp" %>
to the top of each .jsp.
But I noticed a problem. In the Servlet files I created I have a variation of (depending on the jsp page):
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
System.out.println("Login doGet");
request.setAttribute("name", "value");
request.getRequestDispatcher("resources/jsp/login.jsp").forward(request, response);
}
However, in the head.jsp file,
${request.getAttribute("name") != null ? "Logged In" : "Not logged in"}
is causing "Not logged in" to appear when I'm expecting it to say "Logged In" (because I did pass an attribute called "name".
Any ideas what is going on?