I have bean:
Public class User
{
private String name;
public User () { name = "";}
public User (String name) {this.name = name;}
}
in my Servlet, I create and initialized an instance of User, say user,
and add it as an attribute of session:
session.setAttribute ("user", user);
in my jsp, I want to print out the user's name, like this:
<c:if test = "${!empty sessionScope.user}">
welcome ${sessionScope.user.name}
</c:if>
and when try to access this jsp, i got the following exception:
exception:
javax.servlet.ServletException: Unable to find a value for "name" in object of class "User" using operator "."
root cause:
javax.servlet.jsp.el.ELException: Unable to find a value for "name" in object of class "User" using operator "."
If I change the EL expression to expression like:
welcome
<%=((User)session.getAttribute ("user")).getName ()%>
it works fine!
Please help, and thanks in advance!