Win a copy of AWS Security this week in the Cloud/Virtualization 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

TLD files variable element

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Creator of Enthuware JWS+ V6
Posts: 3346
303
Android Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Creator of Enthuware JWS+ V6
Posts: 3346
303
Android Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
 
Put a gun against his head, pulled my trigger, now he's dead, that tiny ad sure bled
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic