Custom JSP label (tag) On
Abstract: Custom JSP label (tag) On
Because of changes in the relationship between the version of this article may not have universal application
<? Xml: namespace prefix = o ns = "urn: schemas-microsoft-com: office: office" />
This article should be read before the article look at the Sun and the best hands-on
Http://java.sun.com/developer/technicalArticles/xml/WebAppDev3/
J2EE API documentation and know the location of the
Http://java.sun.com/j2ee/sdk_1.3/techdocs/api/index.html
Custom Tag is not a very difficult task, Meng is a contact, which they do not know where to start. Recommended first look at Sun's article, reading, there will be a general impression. Have no intention to simple translation of this article, but the article from start to talk about. To say that the sun is in the code documents are completely available, but because of publishing problems, some local branches of the code is not correct, a direct copy of the code to be careful finishing, or they may be passed compiler, deployment When will give you a lot of anomalies.
Custom Tag is javax.servlet.jsp.tagext use package, if compiler problems can go to Tomcat \ common \ lib folder Below find jsp-api.jar quoted on it.
The packet interface inside the class and basically our main concern is to "Tag" at the end of those few, Tag and BodyTag interface, and BodyTagSupport TagSupport category, there is a IterationTag interface, but it is generally not used. We are all the other can be seen as a support class, facilitate access to what information. We can look at the API documentation J2EE on the inside of the package.
Above categories were inside the meaning of the Body may be relatively difficult to understand all of a sudden. Tag refers to as
Tag interface is the root of these classes there, to see what there are. API documentation inside Lifecycle picture that is very rough, but can generally see. We do not dwell too much detail, the general concern is doStartTag () and doEndTag () This paragraph. Whenever you write the tag in Jsp inside pages to be explained, the server will automatically call you the inside of the doStartTag () function to complete your definition of the logic, when call after labelling End Analysis doEndTag (). Tag interface to achieve their own custom tag is the most flexible. However, the more difficulty, we have our own definition of the tag do so totally unnecessary when there are connotations.
BodyTag category also with Tag little difference, BodyTag inherited from the Tag and IterationTag because it involves the Body of reasons, some complex logic. API documentation inside Lifecycle plans also quite clear. It is necessary to see properly. Inside that is the main function call in the order. However, in specific applications, not necessarily to take this step by step throughout the Lifecycle, if the call in order to control these routes. It is necessary to use the return value of the function, the function returns a specific value (defined constants are already) can be changed on the server calls a function under the act to complete your own logic. Here, I can not help but see also admire those people who write libraries, can come up with so one way to solve the problem.
In order to facilitate our development, and provided with two "Support" category to "support" to facilitate our development. Under normal circumstances if we inherited these two categories a, and I think some BodyTagSupport also seems more common. To the point is that the two categories TagSupport Support is the father BodyTagSupport category. Class of getId () and setId () function of the two is not dead, these two "Id" should be in your program you replace the label of, for example, your name is tagname tag is
Here can combine Sun's code look at the documents, see.
As for the deployment and. Tlb file formats, Sun also have documents. Not going to repeat them. Finally finishing attached to the return value list, I think that a more important.
English Evaluate more of the "assessment, and value", I mean, here we can be understood as servers, "read, read, dealing with the" mean, when I translated with some modifications context, underlined the increase below, if misconduct, please correct me.
EVAL_BODY_INCLUDE: Reading the Body to the output stream, doStartTag () function can be used
EVAL_PAGE: to continue to address pages, doEndTag () function can be used
SKIP_BODY: ignore the handling of the Body, doStartTag () and doAfterBody () function can be used
SKIP_PAGE: neglect of the remaining pages with doEndTag () function can be used
EVAL_BODY_TAG: has been abolished, replaced by EVAL_BODY_BUFFERED
EVAL_BODY_BUFFERED: buffer applications from setBodyContent () function to the BodyContent object tag to deal with the body, if the class implements BodyTag, then doStartTag () can be used, otherwise illegal
EVAL_BODY_AGAIN: to continue to address the request body, have returned to the doAfterBody (), the return value of your production cycle when the tag is very useful. I observed what JSTL the source code, to see how it ForEach establishment, but an inside look at the logic extraordinarily complex, a short period of time can not see idea, so here is not rants and raves, if Which Renxiong research, please Comments? spared.
: Packets inside the other categories also not, if research to write a separate document.
↑ Back
Tags: JSP






