Basic jstl problem - Setting a bean property  
Author Message
bobrivers





PostPosted: 2005-2-3 23:16:00 Top

java-programmer, Basic jstl problem - Setting a bean property Hi,

I have a simple class :

public class MyClass {

private String attrib = null;

public MyClass() {}

public void setAttrib(String attrib) {
this.attrib = attrib;
}

public String getAttrib() {
return this.attrib;
}
}

I also have a simple JSP:

<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
<jsp:useBean id="myclass" class="MyClass"/>

If I try to set the "attrib" property using

<c:set target="${myclass}" property="attrib" value="somevalue"/>

I got an error:

javax.servlet.jsp.JspTagException: Invalid property in <set>:
"attrib"
org.apache.taglibs.standard.tag.common.core.SetSupport.doEndTag(SetSupport.java:160)

I tryed target="${myclass.attrib}", but I receive another error:

javax.servlet.jsp.JspException: An error occurred while evaluating
custom action attribute "target" with value "${myclass.attrib}":
Unable to find a value for "attrib" in object of class "MyClass" using
operator "." (null)

Any help?

TIA,

Bob
 
Tobias Schierge





PostPosted: 2005-2-4 1:34:00 Top

java-programmer >> Basic jstl problem - Setting a bean property Hi,

> <c:set target="${myclass}" property="attrib" value="somevalue"/>
^^^^
This should be the name of the bean under which it can be
found in the specified scope.

Regards,

Tobias