JSP EL: How to access static class values?

J

javaguy

I'm writing some JSP pages. I'd like to access some static text:

class myClass {
public static final String PARENT = "PAR";
public static final String CHILD = "CHD";

public static String getChild() { return CHILD; }

...
}

<jsp:useBean id="mine" class="myClass"/>
<c:set var="child" value="${mine.CHILD}"/>
Parent is: <c:eek:ut value="${myClass.PARENT}"/>
Child is: <c:eek:ut value="${child}"/>
Child also is: <c:eek:ut value="${mine.child}"/>


Note that none of this works. The "mine.CHILD" attempt and "myfails
with a warning that

An error occurred while evaluating custom action attribute "value" with
value "${mine.CHILD}": Unable to find a value for "CHILD" in object of
class "myClass" using operator "." (null)

(Tomcat 5.5.4, JDK 1.4.2)


The "mine.child" attempt (calling mine.getChild()) fails silently.
Apparently it returns null and EL converts it to an empty string. Same
thing for "myClass.PARENT".

I know I can get there by using <%= myClass.PARENT %>, but can it be
done through EL alone?

Thanks,

Jerome.
 

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

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top