You are viewing a plain text version of this content. The canonical link for it is here.
Posted to taglibs-user@tomcat.apache.org by "Morrow, Steve D." <SM...@fhlbdm.com> on 2003/11/03 21:01:19 UTC

unable to find value

I have a session-scoped bean structured (in part) as follows:

public class Customer {
 
    public Integer id;
    public String name;
 
    public Integer getId() {
        return id;
    }
 
    public String getName() {
        return name;
    }
}

In the JSP, <c:out value="${customer.name}" /> works as expected. However,
<c:out value="${customer.id}" /> does not - it throws an error that the JSP
is "unable to find a value for "id" in object..." I added the following
method, which works fine with a value of ${customer.ID}:

public String getID() {
    return id.toString();
}

I googled, but was unable to find an answer, or anyone experiencing the same
sort of problem. I'm sure I'm missing something pretty simple, but I could
use some more eyes on the problem. Why is the tag unable to find
${customer.id} (i.e. use the getId() method)?

I am using Jakarta's 1.0.4 taglibs...


This message and any files transmitted with it are confidential and are
intended solely for the use of the individual or entity to whom they are
addressed.  If you have received this email in error, please delete the
email and any files transmitted with it entirely from your computer. 



---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-user-help@jakarta.apache.org


Re: unable to find value

Posted by Kris Schneider <kr...@dotech.com>.
You can use java.beans.Introspector.decapitalize to tell you what the property
name should look like. In this case, Introspector.decapitalize("Id") results in
"id", so you should be fine. I'm sure that's helpful ;-). Are you positive that
your scoped attribute "customer" actually references an instance of your
Customer class? Here's another helpful snippet to see all the properties exposed
by your class:

import java.beans.*;
...
BeanInfo info = Instrospector.getBeanInfo(Customer.class);
PropertyDescriptor[] props = info.getPropertyDescriptors();
for (int i = 0; i < props.length; i++) {
  System.out.println(props[i].getName());
}

Quoting "Morrow, Steve D." <SM...@fhlbdm.com>:

> I have a session-scoped bean structured (in part) as follows:
> 
> public class Customer {
>  
>     public Integer id;
>     public String name;
>  
>     public Integer getId() {
>         return id;
>     }
>  
>     public String getName() {
>         return name;
>     }
> }
> 
> In the JSP, <c:out value="${customer.name}" /> works as expected. However,
> <c:out value="${customer.id}" /> does not - it throws an error that the JSP
> is "unable to find a value for "id" in object..." I added the following
> method, which works fine with a value of ${customer.ID}:
> 
> public String getID() {
>     return id.toString();
> }
> 
> I googled, but was unable to find an answer, or anyone experiencing the
> same
> sort of problem. I'm sure I'm missing something pretty simple, but I could
> use some more eyes on the problem. Why is the tag unable to find
> ${customer.id} (i.e. use the getId() method)?
> 
> I am using Jakarta's 1.0.4 taglibs...

-- 
Kris Schneider <ma...@dotech.com>
D.O.Tech       <http://www.dotech.com/>

---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-user-help@jakarta.apache.org