• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

"declare" element in "variable" element of TLD

 
Ranch Hand
Posts: 115
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

May I know what is the meaning of the <declare> element in the <variable> element of a TLD?
It can be either "true" or "false".
Thanks!
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You may need to access some values set in a tag, and to do so you can use the "variable" tag. The "declare" attribute will force the container to declare a new variable in the calling page, so that the page can access the value set in the tag. "declare" defaults to true. If "declare" is set to false, the variable will not be declared by the container, so it is assumed that the variable already exists in the calling page.

For example (using the variable directive of a Tag File), the following tag will force the container to declare a new variable (java.lang.String extVar ;) in the JSP calling the tag, just before the tag is being used :


If the declare was set to false, this variable would not be declared, assuming there's already an existing variable of the same name.
[ July 28, 2008: Message edited by: Christophe Verre ]
 
Meng Tan
Ranch Hand
Posts: 115
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Christophe for your detailed explanation!

Can I also ask the another question?
How can the variable be accessed by the calling page)?
Is it by means of expression or EL or both?
Thanks!
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Both.
 
Meng Tan
Ranch Hand
Posts: 115
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Christophe!
 
Are we home yet? Wait, did we forget the tiny ad?
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic