Tuesday, October 5, 2010

JSP2.0 simple symbol library extension _SimpleTag



In jsp1.2 era marked a library, and powerful, but the tag library's programming and more complex calls led to the development of real use to the WEB's still not much. JSP2.0 introduced a simple tag library extension to solve the above problems. Simple tag library in a relatively JSP1.2 tag library, the advantages are: on the background of programmers: the structure is more simple and less implement an interface, you can easily daemon

JSP 2.0 has added the new to create self-labeled API: javax.servlet.jsp.tagext.SimpleTag, the API defines the interface used to implement simple tag. And there are interfaces in JSP 1.2 is different, SimpleTag interface does not use the doStartTag () and doEndTag () method, which provides a simple doTag () method. This method is called when the tag is used only once. The need to implement a Self made all the logical process, circulation and body tags are all in the way the assessment is implemented. From this perspective, SimpleTag can IterationTa g achieve the same effect. But SimpleTag methods and processing cycle is much simpler. There is also used to set the SimpleTag JSP content setJspBody () and getJspBody () method. Web container will use setJspBody () method to define a representative of the content of JspFragment JSP object. The program can achieve SimpleTag tag doTag methods needed in multiple calls getJspBody (). Invoke () method to handle JSP content. Production staff for the front page WEB: in JSP1.2 times, Taglib page call is actually more complicated, Simpl eTag + EL expression language greatly simplifies the Taglib call, to really do not know JAVA personnel can easily write JSP The purpose of the page.

Taglib write a page and call consists of three processes:

1. Background programmers to write the procedures to be invoked

Simple signs extension to achieve example:

java program RepeatSimpleTag.java: / / put WEB-INF/classes/jsp2/examples/simpletag following package jsp2.examples.simpletag;





2. Edit Tag flag description file, this file should be placed in WEB-INFjsp2 below, and this document should tld for the end of the file.

repeatTaglib.tld (symbol library description file, on the WEB-INF the following jsp2 below)







Use the label file (JSP fragment): simple tag extension mechanism using another simple way is through the label file. Label file is a resource file, Web page authors can use it to extract some JSP code, through custom functions to achieve code reuse. In other words, the label file to allow JSP page authors use syntax to create reusable JSP tag library. Label the file extension must be ". Tag". Surface label file and jsp1.2 the jsp: include directive in the include file seems to be the same, but in fact there are a few different tags files are generally relatively short and simple functionality and high re-use some code.

----------------------------

A simple tag file SimpleTag.tag this file into the following WEB-INF/tags



Tag file (JSP fragment) of the basic characteristics of the container can handle JSP JSP tag attributes to defer assessment. We know that JSP is first assessed the general attributes of JSP tags, JSP tags and then use in dealing with these properties, and JSP fragment provides a dynamic property. In other words, these attributes in the JSP processing the tag body can be changed when. Tag file is a text file format (JSP syntax) to achieve self-mark, which is a major new feature JSP2.0.

----------------------------

Label the file of tagged documents can be reused as a template to use. TLD attribute directive similar to the element, allowing the custom action attribute declarations.





Tag file for each set of related attributes, and sign documents Tag property set displayed under the corresponding results. Can be used in JSP2.0 tag library is greatly facilitated.







Recommended links:



VOB to MP4



ASF converter



best apple APPLICATIONS for the best fun



MKV To IPod



No comments:

Post a Comment