Pls provide solution to this problem:
The contents of taghandler class are
package tags;
import javax.servlet.jsp.*;
import javax.servlet.jsp.tagext.*;
import java.io.*;
public class myhead extends TagSupport
{
private
String color;
private String fontSize=""20"";
public void setColor(String b)
{
color=b;
}
public void setFontSize(String f)
{
fontSize=f;
}
public int doStartTag()
{
try
{
JspWriter out=pageContext.getOut();
out.println(""<span style=\"" color= ""+color+"";font-size=""+fontSize+""\"">"");
}
catch(IOException e)
{
System.out.println(e);
}
return(EVAL_BODY_INCLUDE);
}
public int doEndTag()
{
try
{
JspWriter out=pageContext.getOut();
out.println(""</span>"");
}
catch(IOException f)
{
System.out.println(f);
}
return (SKIP_PAGE);
}
}
The contents of tag library descriptor heads-taglib.tld are
(I have just omitted the important statements like tlibversion ,jspversion etc to save space)
<tag>
<name>heading</name>
<tagclass>tags.myhead</tagclass>
<bodycontent>
JSP</bodycontent>
<attribute>
<name>color</name>
<required>false</required>
</attribute>
<attribute>
<name>fontSize</name>
<required>false</required>
</attribute>
</tag>
</taglib>
the contents of jsp file are
<HTML>
<HEAD>
<%@ taglib uri=""heads-taglib.tld"" prefix=""he""%>
</head>
<he:heading color=""red"" fontSize=""30"">My Name is Anand</he:heading>
<he:heading color=""green"" fontSize=""40"">My Name is Anand </he:heading>
</html>
The output generated is
A My Name is Anand (red color)
My Name is Anand (green color)
B My Name is Anand(green color)
My Name is Anand(red color)
C My Name is Anand(green color)
D My Name is Anand(red color)