Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Help! Wierd ELException Problem

843838Jan 24 2006
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!
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 21 2006
Added on Jan 24 2006
0 comments
124 views