Hello everybody......
I had tried to run the following programme of custom tag from HFSJ but it throws Exception as: "org.apache.jasper.JasperException: /result.jsp(7,0) According to the TLD or the tag file, attribute user> is mandatory for tag "
my source code in the programme and directory structure as:
1)C:\Program Files\Apache Software Foundation\Tomcat 5.5\webapps\readTld\form.html
2)C:\Program Files\Apache Software Foundation\Tomcat 5.5\webapps\readTld\result.jsp
3)C:\Program Files\Apache Software Foundation\Tomcat 5.5\webapps\readTld\WEB-INF\tlds\test.tld
4)C:\Program Files\Apache Software Foundation\Tomcat 5.5\webapps\readTld\WEB-INF\lib\jstl.jar
5)C:\Program Files\Apache Software Foundation\Tomcat 5.5\webapps\readTld\WEB-INF\lib\standard.jar
6)C:\Program Files\Apache Software Foundation\Tomcat 5.5\webapps\readTld\WEB-INF\classes\foo\AdviserTagHandler.class
And the source code as follows
1) form.html
<html>
<body>
<form action = "result.jsp" method="Get">
<h1> Login Page </h1>
Name:<input type="text"name="userName">
Password:<input type="password"name="userPassword">
<input type = "SUBMIT">
</form>
</body>
</html>
2) result.jsp
<html>
<body>
<%@ taglib prefix="mine" uri="randomThings" %>
Adviser Page
<mine:advice user ="${param.userName}" />
</body>
</html>
3)test.tld
<?xml version="1.0" encoding="ISO-8859-1" ?>
<taglib 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" version="2.0">
<tlib-version>1.1</tlib-version>
<uri>randomThings</uri>
<tag>
<description>random advice</description>
<name>advice</name>
<tag-class>foo.AdviserTagHandler</tag-class>
<body-content>empty</body-content>
<attribute>
<name>user></name>
<required>true</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
</tag>
</taglib>
4) and 5) are jar files
6)
java file of AdviserTagHandler.class is like as:
package foo;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.SimpleTagSupport;
import java.io.IOException;
public class AdviserTagHandler extends SimpleTagSupport
{
private
String user;
public void doTag() throws JspException,IOException
{
getJspContext().getOut().write("Hello"+user+"
");
getJspContext().getOut().write("Your advice is:"+getAdvice());
}
public void setUser(String user)
{
this.user = user;
}
String getAdvice()
{
String[] adviceString = {"That color's is not working for you","
You should call in sick.","You might have to rethink that haircut."};
int random = (int)(Math.random()*adviceString.length);
return adviceString[random];
}
}
so, Please tell me what's wrong in this programme as it says:According to the TLD or the tag file, attribute user> is mandatory for tag