| Author |
TLD files variable element
|
Kevin Vdb
Greenhorn
Joined: Oct 12, 2011
Posts: 1
|
|
Hi all,
I'm preparing for the OCWCD exam. At the moment I'm strubbeling with the <variable> element in TLD files.
What I'm trying to do is reconstruct a question from Enthuware in my project with the following code:
My Taglib:
and in my jsp:
However I'm getting the following error: org.apache.jasper.JasperException: /testTagLib.jsp(12,0) Attribute var invalid for tag advice according to TLD
Any help would be greatly appreciated!
Thanks in advance,
Kevin
|
OCPJP6
|
 |
Frits Walraven
Rancher
Joined: Apr 07, 2010
Posts: 1039
|
|
Hi Kevin,
However I'm getting the following error: org.apache.jasper.JasperException: /testTagLib.jsp(12,0) Attribute var invalid for tag advice according to TLD
You are getting this error because you are declaring a variable that comes from an attribute (<name-from-attribute>), but you didn't decare the attribute var in your tag-entry. Have a look at my examples where I will declare 2 variables: one <name-from-attribute> and one <name-given>:
My TagHandler:
and my jsp:
creating an output of:
start|This is the name kevin of the tag|kevin|end
Regards,
Frits
|
 |
Shashank Sharma
Ranch Hand
Joined: Sep 27, 2006
Posts: 91
|
|
Hello Frits ,
I have the doubt on the same example.
I am using the code snippet as used by kevin but without the nested variables and having only one attribute user.
I have kept <body-content>tag as empty
and am using the tag as
but it says " Expression language not allowed in a template text body".
thanks
|
 |
Frits Walraven
Rancher
Joined: Apr 07, 2010
Posts: 1039
|
|
but it says " Expression language not allowed in a template text body".
This is typically the case when you define a <jsp:attribute> without a <jsp:body> inside a custom tag.
However you defined the body-content as being empty so the container should allow the absence of the <jsp:body>, see this section of the specs:
JSP.5.11 <jsp:body>
Normally, the body of a standard or custom action invocation is defined implicitly as the body of the XML element used to represent the invocation. The body of a
standard or custom action can also be defined explicitly using the <jsp:body> standard action. This is required if one or more <jsp:attribute> elements appear in the
body of the tag. If one or more <jsp:attribute> elements appear in the body of a tag invocation but no <jsp:body> element appears or an empty <jsp:body> element appears, it is
the equivalent of the tag having an empty body.
You have two options now:
create an empty <jsp:body>
or
use the attribute in the way you have seen before:
Regards,
Frits
|
 |
 |
|
|
subject: TLD files variable element
|
|
|