Basic jstl problem - Setting a bean property

Discussion in 'Java' started by Bob Rivers, Feb 3, 2005.

  1. Bob Rivers

    Bob Rivers Guest

    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
    Bob Rivers, Feb 3, 2005
    #1
    1. Advertising

  2. 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
    Tobias Schierge, Feb 3, 2005
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Benjamin Stewart

    To bean or not to bean...

    Benjamin Stewart, Jun 30, 2003, in forum: Java
    Replies:
    0
    Views:
    791
    Benjamin Stewart
    Jun 30, 2003
  2. Robert Mark Bram

    Custom JSTL that accepts JSTL expression

    Robert Mark Bram, Dec 15, 2004, in forum: Java
    Replies:
    0
    Views:
    956
    Robert Mark Bram
    Dec 15, 2004
  3. gbattine
    Replies:
    0
    Views:
    3,090
    gbattine
    Jun 6, 2006
  4. jasdeep
    Replies:
    0
    Views:
    1,802
    jasdeep
    Jul 5, 2006
  5. DaFoot
    Replies:
    1
    Views:
    1,672
    DaFoot
    Oct 23, 2008
Loading...

Share This Page