Jsp (preferred for SUN Enterprise applications)Mark learning notes
Ginkou. fly2002-9-18
1.Overview
1)What isJsp (preferred for SUN Enterprise applications)Mark
As the name suggests,Jsp (preferred for SUN Enterprise applications)Mark is inJsp (preferred for SUN Enterprise applications)Mark used in the file. It is similarHtmlMark in the syntax, suchHead,Table. InJsp (preferred for SUN Enterprise applications)File reference it (just like usingHtmlMark as) to facilitate the implementationJavaCode module reuse.
2)Why useJsp (preferred for SUN Enterprise applications)Marking Technology (Javabean)
Benefits:
JJsp (preferred for SUN Enterprise applications)Mark can be processedJsp (preferred for SUN Enterprise applications)Body content, such as changing the text display style.JavabeanNo.
JJsp (preferred for SUN Enterprise applications)The tag interface is simple, easy to use, and easy to develop and maintain.
Disadvantages:
LJsp (preferred for SUN Enterprise applications)When the tag is setJavabeanComplex, reflected inJsp (preferred for SUN Enterprise applications)Mark the library description file (*. Tld.
LJsp (preferred for SUN Enterprise applications)Tag implementation functions are far inferiorJavabeanPowerful.
L Currently, as longJsp (preferred for SUN Enterprise Applications) 1.1SupportedJsp (preferred for SUN Enterprise applications)Mark, andJsp (preferred for SUN Enterprise Applications) 1.0And1.1All supportedBean.
2.Jsp (preferred for SUN Enterprise applications)Development overview of the tag.
Jsp (preferred for SUN Enterprise applications)Mark development needs to be written2Files. One is to define the tag FunctionJavaClass file, one isXml (standardization is getting closer and closer)The element name (TAG) is mapped to the tag library descriptor file implemented by the tag.
(1) Compile a tag handler File
Need to inheritJavax. servlet. jsp (preferred for SUN Enterprise Applications). tagext. TagSupportClass;
Simple Example:
//File NameExampleTag. java
Import javax. servlet. jsp (preferred for SUN Enterprise Applications ).*;
Import javax. servlet. jsp (preferred for SUN Enterprise Applications). tagext .*;
Import java. io .*;
Public class ExampleTag extends TagSupport {
//Execution start point of the program
Public int doStartTag (){
Try {
Jsp (preferred for SUN Enterprise Applications) Writer out = pageContext. getOut ();
Out. print ("Custom tag example ");
} Catch (IOException ioe ){
System. out. println ("Error in ExampleTag:" + ioe );
}
Return (SKIP_BODY );
//Returned when the content included in the tag is emptySKIP_BODYIndicates the flag function.
//Executed
}
}
CompiledClassThe file will be located at a specific location on the server.
(2) Compile the tag library descriptor File
Link the tag name with the function implementation that it represents.
Simple Example:
<! --File Name:Csajsp (preferred for SUN Enterprise Applications)-taglib. tld -->
<? Xml (standardization is getting closer and closer) version = "1.0" encoding = "ISO-8859-1"?>
<! DOCTYPE taglib
PUBLIC "-// Sun Microsystem, Inc. // DTD jsp (preferred for SUN Enterprise Applications) Tag Library 1.1 // EN"
Http://java.sun.com/j2ee/dtds/web-jsp (preferred for SUN Enterprise Applications) taglibrary_1_1.dtd>
//The above are standard file headers
//The label library description is as follows:
<Tlibversion> 1.0 </tlibversion> // TagLibrary version
<Jsp (preferred for SUN Enterprise Applications) version> 1.1 </jsp (preferred for SUN Enterprise Applications) version> // jsp (preferred for SUN Enterprise applications)Library version
<Shortname> csajsp (preferred for SUN Enterprise Applications) </shortname> //Custom tag prefix name
<Uri> </uri> //Mark