What is JSP TAG pull? If you know HTML, XML, you should know tag. Any TAG-based language (such as HTML) must be between '<' and '>'.
Package com.stardeveloper.tag.test;
Import java.io. *;
Import javax.servlet.jsp. *;
Import javax.servlet.jsp.tagext. *;
Public class firstttag imports tag, serializable {
Private pageContext PC = NULL;
PRIVATE TAG PARENT = NULL;
Private string name = NULL;
Public void setPageContext (PageContext P) {
PC = P;
}
Public void setparent (tag t) {
Parent = T;
}
Public tag getparent () {
Return Parent;
}
Public void setname (string s) {
Name = s;
}
Public string getname () {
Return Name;
}
Public int desartTartTag () throws jspexception {
Try {
IF (name! = null) {
Pc.getout (). Write ("Hello" Name "!");
} else {
Pc.getOut (). Write ("You Didn't Enter your name"); pc.getout (). Write (", What are you Afraid of?");
}
} catch (ioexception e) {
Throw new jsptagexception ("an ioexception iocurred.");
}
Return Skip_body;
}
PUBLIC INT DOENDTAG () THROWS JSPEXCEPTION {
Return Eval_page;
}
Public void release () {
PC = NULL;
Parent = NULL;
Name = NULL;
}
} Note: Package com.stardeveloper.tag.test; indicates that the firstttag class is packaged and placed in com.stardeveloper.tag.test. 2. Introducing three packages (we use the methods and classes in them) Import java.io . *;
Import javax.servlet.jsp. *;
Import javax.servlet.jsp.tagext. *; Note these two sense interfaces Serializable and Tag, which is not necessary for creating a JSP tags class, and tag is the most important