• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

how to access a constant from JSTL

 
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
I have a constant

public static final long PIN = 1;
which I am using in my jsp
var pin_no = -> %=CONSTANTS.PIN% -<

I am testing like this
-> c:if test="${form.state == pin_no}" -<

But I am not able to get the value.

Please let me know how to do access a constant in the JSP.

Thanks.
 
Sheriff
Posts: 67754
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You cannot reference either a constant or a scripting variable from the EL. You will need to set the value as a scoped variable for it to become EL-accessbile.
 
Chitti pokala
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
can you please let me know what is scoped variable?

Thanks in advance.
 
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Bear, didn't you have an excellent Journal entry on this very topic here?
 
Bear Bibeault
Sheriff
Posts: 67754
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Beat me to it! Was looking for the link...

A scoped variable is an object placed into one of the scoped contexts using that context's setAttribute() method.
[ September 12, 2005: Message edited by: Bear Bibeault ]
 
Chitti pokala
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
I am accessing the constant from an Interface not from a class.
Please let me know how to access a constant from an interface within JSTL.

Thanks in advance.
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Chitti pokala:
Hi
I am accessing the constant from an Interface not from a class.
Please let me know how to access a constant from an interface within JSTL.

Thanks in advance.




You cannot reference either a constant or a scripting variable from the EL. You will need to set the value as a scoped variable for it to become EL-accessbile.



Which would mean that somewhere you would need to set that constant as a scoped variable. For example...



Then you can access someValue in your JSP via EL/JSTL.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic