You are viewing a plain text version of this content. The canonical link for it is here.
Posted to taglibs-user@tomcat.apache.org by Kelly Harward <ke...@oakleynetworks.com> on 2003/07/11 01:40:17 UTC

Using JSP scriptlets to specify parameter values of custom tags

I have a question over which I have been beating my head against a wall -
perhaps you can help...

I've written a custom tag library that seems to work wonderfully - except
for one significant caviat. The parameters of my tags cannot accept String
values obtained by evaluating a JSP scripting variable. For example, when I
try the following:

<mylib:hello name="<%= yourName %>" />

The entire String literal ("<%= yourName %>") is passed through to the tag
as the value of that parameter. It appears that the JSP engine is not
evaluating the value of this expression prior to setting that parameter of
the given tag. I know the JSTL and Jakarta libraries do not behave this way.

Any ideas regarding what I am missing?


---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-user-help@jakarta.apache.org


Re: Using JSP scriptlets to specify parameter values of custom tags

Posted by Eric W Hauser <eh...@indiana.edu>.
you may want to consider accepting EL as parameters to your tags...this is
much cleaner than using scriptlets...i did some googling for you and found
a good article on how to do this:

http://www.onjava.com/lpt/a/2864

this should get you well on your way...

On Thu, 10 Jul 2003, N. Chen wrote:

> 
> 
> well, you have to set
> <rtexprvalue>true</rtexprvalue>
> 
> for attribute name in your tld, i think.
> 
> <attribute>
>   <name>name</name>
>   <rtexprvalue>true</rtexprvalue>
>   <type>String</type>
> </attribute>
> 
> nick
> On Thu, 10 Jul 2003, Kelly Harward wrote:
> 
> > I have a question over which I have been beating my head against a wall -
> > perhaps you can help...
> >
> > I've written a custom tag library that seems to work wonderfully - except
> > for one significant caviat. The parameters of my tags cannot accept String
> > values obtained by evaluating a JSP scripting variable. For example, when I
> > try the following:
> >
> > <mylib:hello name="<%= yourName %>" />
> >
> > The entire String literal ("<%= yourName %>") is passed through to the tag
> > as the value of that parameter. It appears that the JSP engine is not
> > evaluating the value of this expression prior to setting that parameter of
> > the given tag. I know the JSTL and Jakarta libraries do not behave this way.
> >
> > Any ideas regarding what I am missing?
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: taglibs-user-help@jakarta.apache.org
> >
> >
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: taglibs-user-help@jakarta.apache.org
> 
> 
> 

-------------------
Eric Hauser
ehauser@indiana.edu
(317) 679-4766


---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-user-help@jakarta.apache.org


Re: Using JSP scriptlets to specify parameter values of custom tags

Posted by "N. Chen" <ni...@u.washington.edu>.

well, you have to set
<rtexprvalue>true</rtexprvalue>

for attribute name in your tld, i think.

<attribute>
  <name>name</name>
  <rtexprvalue>true</rtexprvalue>
  <type>String</type>
</attribute>

nick
On Thu, 10 Jul 2003, Kelly Harward wrote:

> I have a question over which I have been beating my head against a wall -
> perhaps you can help...
>
> I've written a custom tag library that seems to work wonderfully - except
> for one significant caviat. The parameters of my tags cannot accept String
> values obtained by evaluating a JSP scripting variable. For example, when I
> try the following:
>
> <mylib:hello name="<%= yourName %>" />
>
> The entire String literal ("<%= yourName %>") is passed through to the tag
> as the value of that parameter. It appears that the JSP engine is not
> evaluating the value of this expression prior to setting that parameter of
> the given tag. I know the JSTL and Jakarta libraries do not behave this way.
>
> Any ideas regarding what I am missing?
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: taglibs-user-help@jakarta.apache.org
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-user-help@jakarta.apache.org