Basic jstl problem - Setting a bean property

B

Bob Rivers

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
 
T

Tobias Schierge

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top