• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Tag files

 
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am trying to use tag files

Here is my JSP file

<%@ taglib prefix="myTags" tagdir="/WEB-INF/tags" %>
<html>
<body>
Welcome <br/>
<myTags:Header sub="SUBTITLE"/>
</body>
</html>

and here is the tag file
<%@ attribute name="sub" required="true" rtexprvalue="true" %>

In the Included Header File <br/>
${sub}

But when i call the jsp file it gves me following error

org.apache.jasper.JasperException: /abc.jsp(5,2) Unable to find setter method for attribute: sub
org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:83)
org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:402)
org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:186)
org.apache.jasper.compiler.Generator$GenerateVisitor.evaluateAttribute(Generator.java:2658)
org.apache.jasper.compiler.Generator$GenerateVisitor.generateSetters(Generator.java:2806)
org.apache.jasper.compiler.Generator$GenerateVisitor.generateCustomDoTag(Generator.java:2350)
org.apache.jasper.compiler.Generator$GenerateVisitor.visit(Generator.java:1673)
org.apache.jasper.compiler.Node$CustomTag.accept(Node.java:1458)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2180)
org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2230)
org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2236)
org.apache.jasper.compiler.Node$Root.accept(Node.java:485)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2180)
org.apache.jasper.compiler.Generator.generate(Generator.java:3253)
org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:277)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:456)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:439)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:552)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:291)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:301)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:248)
javax.servlet.http.HttpServlet.service(HttpServlet.java:856)





But the following works fine

Inside JSP
<%@ taglib prefix="myTags" tagdir="/WEB-INF/tags" %>
<html>
<body>
Welcome <br/>
<myTags:Header> Inside Tag</myTags:Header>
</body>
</html>

Inside tag


In the Included Header File <br/>
<jsp oBody/>
 
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Make sure your tag file Header.tag is in WEB-INF/tags directory. Looks like container unable to find it.

:roll:
[ February 22, 2005: Message edited by: Deb Sadhukhan ]
 
Sharma Anjali
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Deb Sadhukhan:
Make sure your tag file Header.tag is in WEB-INF/tags directory. Looks like container unable to find it.

:roll:

[ February 22, 2005: Message edited by: Deb Sadhukhan ]



Header.tag is inside the WEB-INF/tags directory. Thats why the following works
(as posted above)
nside JSP
<%@ taglib prefix="myTags" tagdir="/WEB-INF/tags" %>
<html>
<body>
Welcome <br/>
<myTags:Header> Inside Tag</myTags:Header>
</body>
</html>

Inside tag


In the Included Header File <br/>
<jsp: doBody/>
 
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

...and here is the tag file
<%@ attribute name="sub" required="true" rtexprvalue="true" %>

In the Included Header File <br/>
${sub}

But when i call the jsp file it gves me following error
org.apache.jasper.JasperException: /abc.jsp(5,2) Unable to find setter method for attribute: sub
org.apache.jasper.compiler.



I believe your Tomcat-generated java for the jsps is out of sync. (There's no setSub() getSub()) Could it be that Tomcat is using an older version of your tag file before you added the attribute? You could look at the generated java version of the jsps. Try resetting Tomcat: start & stop; or create a copy called MyHeaderB, and see if it works.

What's the full tag file look like?
[ February 23, 2005: Message edited by: P. Dunn ]
 
Deb Sadhukhan
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
See Anjali, I was just trying to help you by saying make sure you have tag file in correct location. People do all sorts of stupid mistakes, putting tag file in one application's dir and trying to access from another application and it happens to me also. You don't have to be so rude - quoting me and then pointing out in your original posting where I can find answer for my question. If you are so confident you have done everything right, then why it's not working for you? It works for me in my system.
 
Sharma Anjali
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Deb Sadhukhan:
See Anjali, I was just trying to help you by saying make sure you have tag file in correct location. People do all sorts of stupid mistakes, putting tag file in one application's dir and trying to access from another application and it happens to me also. You don't have to be so rude - quoting me and then pointing out in your original posting where I can find answer for my question. If you are so confident you have done everything right, then why it's not working for you? It works for me in my system.



Do you think quoting someone is being rude?
It's only meant to specify which point you are answering.
 
Good heavens! What have you done! Here, try to fix it with this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic