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 ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • 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" %>

<html>
<head>
<title>Header Tags Example</title>
</head>

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

${x}

<myTags:Header subTitle="We take the Sting out of SOAP" >
${x}
</myTags:Header>

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

</body>
</html>

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?.

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