Win a copy of Microservices Testing (Live Project) this week in the Spring forum!
  • 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 ...
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

@Variable Directive

Ranch Hand
Posts: 120
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have tried to see the working of Variable directive in Tag Files.

The expression ${x} does not get evaluated. Why?

Tag File : ( Header.Tag )

<%@ variable name-given="x" scope="AT_END" %>
<c:set var="x" value="5" />

<%@ attribute name="subTitle" required="true" rtexprvalue="true" %>

<img src="GTITLE.gif"> <br>
<h1>Hi, </h1>
<em><strong>${subTitle}</strong></em> <br>

JSP File : ( Header.JSP)

<%@ taglib prefix="myTags" tagdir="/WEB-INF/tags" %>

<title>Header Tags Example</title>

<body bgcolor="#660099">
<h3>Simple Header Tag</h3>


<myTags:Header subTitle="We take the Sting out of SOAP" >

<c ut value="${x}" />
Welcome to our site.


Actually in the source I could see the value of x being set to 5.
But, the expression of ${x} is not evaluated.
I tried all three properties, AT_END, AT_BEGIN & NESTED.
Ranch Hand
Posts: 380
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Sunder,

When you specify :

Means x is a variable whose value will be going out from the tag to the calling jsp file. Its an OUT (or like a return type variable)....

In the Tag file you can modify the value.

Doing so would allow the ~~return value to be synchronized depending on the scope specified.

Also note, that the OUT variables do not get initialized with the values specified in the calling jsp files - but are only capable of setting values in these variable - that are to be returned.

Note: I do hope that you are importing the Jstl core library in the tag file so that c:set works correctly?.

[ July 25, 2006: Message edited by: Shivani Chandna ]
    Bookmark Topic Watch Topic
  • New Topic