tags:

views:

50

answers:

0

Hi, in my application I am getting a problem which is like Http status-500, I think the problem is in the tld, but really i don't get what is the problem, I'm posting the codes below please check it out and tell me where is the problem.

import javax.servlet.jsp.*;
import javax.servlet.jsp.tagext.*;
public class RequiredTag implements Tag
{
private PageContext pageContext;
private Tag parentTag;
public void setPageContext(PageContext pageContext)
{
this.pageContext = pageContext;
}
public void setParent(Tag parentTag)
{
this.parentTag = parentTag;
}
public Tag getParent()
{
return this.parentTag;
}
public int doStartTag() throws JspException
{
try
{
JspWriter out = pageContext.getOut();
out.print("<font color='#ff0000'>*</font>");
}
catch(Exception e)
{
throw new JspException("Error in RequiredTag.doStartTag()");
}
return SKIP_BODY;
}
public int doEndTag() throws JspException
{
return EVAL_PAGE;
}
//clean up the resources (if any)
public void release()
{
}
}

the tld code is

<taglib version="2.0">
<tlib-version>1.2</tlib-version>
<uri>sampleLib.tld</uri>
<tag>
    <name>required</name>
    <tag-class>RequiredTag</tag-class>
    <body-content>empty</body-content>
</tag>
</taglib>

the jsp page is

<%@ taglib uri="sampleLib.tld" prefix="test" %>
<html>
Please enter your address and click submit.<br>
The fields marked with a <test:required /> are mandatory.
<form action="validateAddress.jsp">
<table>
<tr>
<td><test:required /> Street 1</td>
<td><input TYPE='text' NAME='street1'></td>
</tr>
<tr>
<td> Street 2</td>
<td><input TYPE='text' NAME='street2'></td>
</tr>
<tr>
<td> Street 3</td>
<td><input TYPE='text' NAME='street3'></td>
</tr>
<tr>
<td><test:required/> City </td>
<td><input TYPE='text' NAME='city'></td>
</tr>

<tr>
<td><test:required/> State </td>
<td><input TYPE='text' NAME='state'></td>
</tr>
<tr>
<td><test:required /> Zip </td>
<td><input TYPE='text' NAME='zip'></td>
</tr>
</table>
<input TYPE='submit' >
</form>
</html>