Hi Arun,

There is no direct way to access constants in the EL.  Here are a few
alternatives:

1. Create a Map in the application scope and put all the constants in
there.  (e.g. ${myConstantsMap.SOME_CONST})

2. Create a bean that implements java.util.Map and have it look up
constants (e.g. ${constantsBean.MyConstants.SOME_CONST} would call
constantsBean.get( "MyConstants" ).  This would return a Map containing
key/value pairs for the costants in MyConstants).  This is not hard to
write and could be done using introspection.

3. Create a function that looks up the constants (e.g. ${fn:constants(
"MyConstants.SOME_CONST" )} ).  Again, The function would use introspection.

We're looking into making this easier in a future version of the JSP
specification.

Hope this helps.

---
Mark Roth, Java Software
JSP 2.0 Co-Specification Lead
Sun Microsystems, Inc.


Karthik Arun wrote:
hi All

How can I use a Const (final static) member of a class MyConstants in JSTL??
I would like to do something like this:

<c:if test="${state == MyConstants.SOME_CONST}" >
  <c:set value="${stateCode + '<br><b>' + singleObjToProcess.stateStr +
'</b><br>'}" var="stateCode" />
</c:if>

where SOME_CONST is a const in MyConstants class.state is a loop iterating
variable, stateCode is some member variable of singleObjToProcess object
that is in the page scope.

Can somebody let me know how I can use the constant in the JSTL..????

Regards,
Arun Karthik R



===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".

Some relevant archives, FAQs and Forums on JSPs can be found at:

 http://java.sun.com/products/jsp
 http://archives.java.sun.com/jsp-interest.html
 http://forums.java.sun.com
 http://www.jspinsider.com

=========================================================================== To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST". For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".

Some relevant archives, FAQs and Forums on JSPs can be found at:

http://java.sun.com/products/jsp
http://archives.java.sun.com/jsp-interest.html
http://forums.java.sun.com
http://www.jspinsider.com

Reply via email to