Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

how to access a constant from JSTL  RSS feed

 
Chitti pokala
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • 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.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66141
141
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
can you please let me know what is scoped variable?

Thanks in advance.
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear, didn't you have an excellent Journal entry on this very topic here?
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66141
141
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • 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
  • 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
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • 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.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!