Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Passing runtime variables to jsp 2.0 tag files.

 
Francesco Marchioni
author
Ranch Hand
Posts: 194
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
I'd like to use tag files to build some templates in my web pages.
My problem is that I need to pass variables at runtime


Unfortunately I cannot use standard jsp <%=myvar%> notation like this:

<% String myvar="blabla"; %>

<tags ageHeading title="<%=myvar%>" />

So which is the correct way to pass runtime parameters to tag files?
Thanks a lot
Francesco
 
Abhimanyu Kumar
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Francesco Marchioni:
Hi all,
I'd like to use tag files to build some templates in my web pages.
My problem is that I need to pass variables at runtime


Unfortunately I cannot use standard jsp <%=myvar%> notation like this:

<% String myvar="blabla"; %>

<tags ageHeading title="<%=myvar%>" />

So which is the correct way to pass runtime parameters to tag files?
Thanks a lot
Francesco



Hi Francesco,
if you are using custom taglibs, then in the tld file , you can specify rtexprvalue = true for that parameter
eg.
<tag>
<name>TextInput</name>
<tagclass>blah.web.taglib.TextInputTag</tagclass>
<bodycontent>JSP</bodycontent>
<info>Writing text inputs</info>
<attribute>
<name>name</name>
<required>true</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
</tag>

with this tld , in jsp i have statements like
<% String myName = "Abhimanyu" ; %>

<html:TextInput name="<%=myName%>" />

Hope this helps,
Abhimanyu
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!