playerone
asked on
JSP Custom Tag Attribute
Hi,
I've written myself a custom tag for a JSP, but i'm having a little trouble passing it an attribute.
The tag is supposed to be passing a parameter from a form that was submitted from a previous page, so i'm using:
<tag:hashingTag valueToHash="${param.answe r}" />
This is what i've been using for the standard tags to pass variables, but for my tag it just passes in the String "${param.answer}", rather than the value that variable is holding.
Is there some setting i'm supposed to set to tell the tag this is a variable, not a String?
Cheers.
I've written myself a custom tag for a JSP, but i'm having a little trouble passing it an attribute.
The tag is supposed to be passing a parameter from a form that was submitted from a previous page, so i'm using:
<tag:hashingTag valueToHash="${param.answe
This is what i've been using for the standard tags to pass variables, but for my tag it just passes in the String "${param.answer}", rather than the value that variable is holding.
Is there some setting i'm supposed to set to tell the tag this is a variable, not a String?
Cheers.
Reading your post again, since you're successfully using "${...}" with the standard tags, then it would point to the problem being in your .tld file, and needing to declare <rtexprvalue>true</rtexprv alue> within the appropriate <attribute> elements.
ASKER
Thanks, but I'm already using <rtexprvalue>true</rtexprv alue>, here is this tag from my tld file:
<tag>
<name>hashingTag</name>
<tagclass>tags.HashingTag< /tagclass>
<attribute>
<name>valueToHash</name>
<required>true</required>
<rtexprvalue>true</rtexprv alue>
</attribute>
</tag>
<tag>
<name>hashingTag</name>
<tagclass>tags.HashingTag<
<attribute>
<name>valueToHash</name>
<required>true</required>
<rtexprvalue>true</rtexprv
</attribute>
</tag>
>> <tag:hashingTag valueToHash="${param.answe r}" />
if you are not on a jsp2.0 server, you cannot use this as is.
let us know what server are you using?
if you are not on a jsp2.0 server, you cannot use this as is.
let us know what server are you using?
ASKER
I'm currently using Tomcat 5 (although the page may be needed to run on Tomcat 4)
tomcat4 is jsp1.2, which doesn't support EL. you cannot use that in tomcat4.
if you have to do it for tomcat4, you'll need to parse the EL yourself. jakarta has a lib to do that.
let us know if your have further enquires.
if you have to do it for tomcat4, you'll need to parse the EL yourself. jakarta has a lib to do that.
let us know if your have further enquires.
ASKER
Ok, i've found the commons el lib on jakarta's website, but i can't find anything about how to use it!
I've downloaded the binary and put it in the lib folder for my app but can't see what to do next.
I've downloaded the binary and put it in the lib folder for my app but can't see what to do next.
you'll need to change your tag lib to call the el lib, I'm trying to find you some code that I did before.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
hold on, I just had a quick look at the el lib you found in jakarta, that one seems too requires jsp 2.0, I cannot be sure.
It is a very confused in el between jsp1.2/jstl1.0 and jsp2.0/jstl1.1. I would say, if your tag is going to be end up used in tomcat 4, you should probably stick developing on tomcat 4 as well. forget about the el lib, just use the one come with jstl1.0 (standard.jar and jstl.jar) my code above works with jstl1.0.
It is a very confused in el between jsp1.2/jstl1.0 and jsp2.0/jstl1.1. I would say, if your tag is going to be end up used in tomcat 4, you should probably stick developing on tomcat 4 as well. forget about the el lib, just use the one come with jstl1.0 (standard.jar and jstl.jar) my code above works with jstl1.0.
ASKER
yeah, thats done the trick!
my tags now running on Tomcat 4,
cheers!
my tags now running on Tomcat 4,
cheers!
http://java.sun.com/j2ee/1.4/docs/tutorial/doc/JSPIntro7.html
Depending on your application server, you may need to specify (at the top of your page)
<%@ page isELIgnored="false" %>
Additionally, the attributes on your custom tags must be set up in the tld file as <rtexprvalue>true</rtexprv