<bean:write and struts errors....


Web tier: servlets, JSP, Web frameworks: <bean:write and struts errors....

  1. <bean:write and struts errors.... (2 messages)

    hi to all i'am sorry of my english and i hope that you could help me.

    i have a problem:

    I have a bean class "UsersClass" that has 2 fields:
    int userId, and String userName.
    This class has both the "get" and "set" methods of the fields.

    In an Action of struts i instanziate the Class

    UserClass user = new UserClass();
    request.setAttribute("user", user);

    and set it in the request
    then in the jsp i use this code to see the properties of the class.

    1) <bean:write name="user" property="username" />
    2) <bean:write name="user" property="userId" />

    but if i write only the first properties "username" i see the property normally, but if i use also the properties "userId" i receive in a jsp an error. Is it normal? Where is the mistake?

    I use Tomcat 5.5

    best regards Andrea from Roma Italia
  2. hm - could you show the stack trace of the error?

    is "username" correct - should it not be "userName", but this one works, strange...
  3. Try this:
    <bean:write name="user" property="userId" format=""/>