I'm having trouble with a custom tag:-
org.apache.jasper.JasperException: /custom_tags.jsp(1,0) Unable to find setter method for attribute : firstname
This is my TagHandler class:
package com.cg.tags;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.tagext.TagSupport;
public class NameTag extends TagSupport{
public String firstname;
public String lastname;
public void setFirstName(String firstname){
this.firstname=firstname;
}
public void setLastName(String lastname){
this.lastname=lastname;
}
public int doStartTag() throws JspException {
try {
JspWriter out=pageContext.getOut();
out.println( "Frist name: "+firstname+ "Last name: "+lastname);
} catch (Exception ex) {
throw new JspException("IO problems");
}
return SKIP_BODY;
}
}
This is my TLD file:
?xml version="1.0" encoding="UTF-8"?>
<taglib>
<tlibversion>1.1</tlibversion>
<jspversion>1.1</jspversion>
<shortname>utility</shortname>
<uri>/WEB-INF/nametagdesc.tld</uri>
<info>
A simple tag library for the examples
</info>
<tag>
<name>name</name>
<tagclass>com.cg.tags.NameTag</tagclass>
<bodycontent>empty</bodycontent>
<attribute>
<name>firstname</name>
<required>true</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>lastname</name>
<required>true</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
</tag>
</taglib>
And this is my JSP page:
<%@ taglib uri="/WEB-INF/nametagdesc.tld" prefix="cg" %>
<cg:name firstname="fname" lastname="lname"/>
I have checked that the code is recompiled and deployed correctly etc etc....
So, the question is , why can't it find the setter method???