jQuery in Action, 2nd edition*
The moose likes Servlets and the fly likes Why i got error when i run the the code Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Servlets
Reply locked New topic
Author

Why i got error when i run the the code

Indravadan T Patel
Greenhorn

Joined: Sep 09, 2007
Posts: 29
Hi All,

i here show you my JSP, TLD and Taghandler class.
----------------------------------
<%@ taglib uri="/WEB-INF/tlds/SimpleTag.tld" prefix="csajsp" %>
<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>

<csajsp:Multi length="20"/><br>
<csajsp:Multi length="40"/>

</body>
</html>
----------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<taglib version="2.0" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee web-jsptaglibrary_2_0.xsd">
<tlib-version>1.0</tlib-version>
<short-name>simpletag</short-name>
<uri>/WEB-INF/tlds/SimpleTag</uri>
<tag>
<name>Multi</name>
<tag-class>indra.SimplePrimeTag</tag-class>
<body-content>empty</body-content>
<attribute>
<name>length</name>
<required>true</required>
</attribute>
</tag>
</taglib>
------------------------------------------------
package indra;

import java.math.BigInteger;
import javax.servlet.jsp.tagext.*;
import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.JspException;
import java.io.*;
import java.math.*;
public class SimplePrimeTag extends TagSupport {
private String length="60";
// private boolean length;

public int doStartTag() {
try {
JspWriter out = pageContext.getOut();
int len = Integer.parseInt(getLength());
out.println("Multiplication :" +len*len);
} catch (Exception ex) {

}

return (SKIP_BODY);
}


public boolean isLength(){
return true;
}

public void setLength(String length) {
this.length = length;
}

public String getLength() {
return length;
}



}
---------------------------------
and i got error like that :

org.apache.jasper.JasperException: /index.jsp(11,12) Unable to find setter method for attribute: length
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:510)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:375)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:368)

-----------------------------

Regards,
Indravadan Patel
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14688
    
  16

Please do not duplicate posts. Continue the discussion in the original thread.


[My Blog]
All roads lead to JavaRanch
 
 
subject: Why i got error when i run the the code