This week's book giveaway is in the Design forum.
We're giving away four copies of Mastering Non-Functional Requirements and have Sameer Paradkar on-line!
See this thread for details.
Win a copy of Mastering Non-Functional Requirements this week in the Design forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

@Variable Directive  RSS feed

Sunder Ganapathy
Ranch Hand
Posts: 120
  • Mark post as helpful
  • send pies
  • 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.
Shivani Chandna
Ranch Hand
Posts: 380
  • Mark post as helpful
  • send pies
  • 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 ]
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!