This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Tag files Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Tag files" Watch "Tag files" New topic
Author

Tag files

Sharma Anjali
Ranch Hand

Joined: Feb 22, 2005
Posts: 63
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/>
Deb Sadhukhan
Ranch Hand

Joined: Nov 05, 2003
Posts: 67
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 ]

_ __ _ __ _ __ _<br />SCJP 1.4 (95%) | SCWCD 1.4 (79%)<br />Artificial intelligence is no match for natural stupidity.
Sharma Anjali
Ranch Hand

Joined: Feb 22, 2005
Posts: 63
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/>
P. Dunn
Ranch Hand

Joined: Feb 22, 2005
Posts: 34
...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 ]

P.Dunn<br />SCJP, SCJD, SCEA & SCWCD
Deb Sadhukhan
Ranch Hand

Joined: Nov 05, 2003
Posts: 67
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

Joined: Feb 22, 2005
Posts: 63
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Tag files
 
Similar Threads
Tag File
Can somebody help me with jsp:invoke?
custom tag doubt
Mails thru JSP
Error while passing tag attribute(Tag files)