title: JSP custom tag library (Unable to find setter method for the attribute)
body: <p>I'm having trouble with a custom tag:-</p>
  
  <p>org.apache.jasper.JasperException: /custom_tags.jsp(1,0) Unable to find setter method for attribute : firstname</p>
  
  <p>This is my TagHandler class:</p>
  
  <pre><code>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( "First name:  "+firstname+ "Last name: "+lastname);
  
          } catch (Exception ex) {
              throw new JspException("IO problems");
          }
          return SKIP_BODY;
      }
  
  
  }
  </code></pre>
  
  <p>This is my TLD file:</p>
  
  <pre><code>?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;taglib&gt;
       &lt;tlibversion&gt;1.1&lt;/tlibversion&gt;
       &lt;jspversion&gt;1.1&lt;/jspversion&gt;
       &lt;shortname&gt;utility&lt;/shortname&gt;
       &lt;uri&gt;/WEB-INF/nametagdesc.tld&lt;/uri&gt;
       &lt;info&gt;
         A simple tag library for the examples
       &lt;/info&gt;
     &lt;tag&gt;
         &lt;name&gt;name&lt;/name&gt;
         &lt;tagclass&gt;com.cg.tags.NameTag&lt;/tagclass&gt;
         &lt;bodycontent&gt;empty&lt;/bodycontent&gt;
        &lt;attribute&gt;
        &lt;name&gt;firstname&lt;/name&gt;
        &lt;required&gt;true&lt;/required&gt;
        &lt;rtexprvalue&gt;true&lt;/rtexprvalue&gt;
        &lt;/attribute&gt;
        &lt;attribute&gt;
        &lt;name&gt;lastname&lt;/name&gt;
        &lt;required&gt;true&lt;/required&gt;
        &lt;rtexprvalue&gt;true&lt;/rtexprvalue&gt;
      &lt;/attribute&gt;
   &lt;/tag&gt;
  &lt;/taglib&gt;
  </code></pre>
  
  <p>And this is my JSP page:</p>
  
  <pre><code>&lt;%@ taglib uri="/WEB-INF/nametagdesc.tld" prefix="cg"  %&gt;
  
  &lt;cg:name firstname="fname" lastname="lname"/&gt;
  </code></pre>
  
  <p>I have checked that the code is recompiled and deployed correctly etc etc....</p>
  
  <p>So, the question is , why can't it find the setter method???</p>