ivancoene
ivancoene

Reputation: 170

Reading session values in jsp

I'm making a website with JSP but I'm stucked at the login mechanism. When someone is logged-in an User-bean is made and send by a session like this (u is filled in before that with a name):

session.setAttribute("User", u);

The part where I'm stucked is the reading part. Where I want to do something like this:

<c:choose>
    <c:when test="${empty user}">
        <c:import url="notlogedin.jsp"/>
    </c:when>
    <c:otherwise>
        <p><b>Name: </b> ${user.name}</p>
    </c:otherwise>
</c:choose>

Sorry if it's unclear, I'm really new in Web programming with Java...

Upvotes: 1

Views: 65

Answers (1)

Luiggi Mendoza
Luiggi Mendoza

Reputation: 85789

The names are case sensitive. You're storing the session attribute with "User" (capital U) and reading it as user (no capitals at all). Choose one word only.

Upvotes: 1

Related Questions