Compile-time tags (XSLT preprocessing of JSP)

Source: Internet
Author: User
Tags add format expression html form implement reset xslt
js| compile an old text, turn it over and review it. BTW, protesting the classification of CSDN, how can XML be attributed to. NET!!

Sender: Hax (Hai Xi), letter area: Webdevelop

Title

Letter Station: Drink from (February 12, 2002 00:10:32 Tuesday), Station letters



Compile-time tags (XSLT preprocessing of JSP)



Original: http://www.mail-archive.com/taglibs-dev@jakarta.apache.org/msg00390.html



From:james Strachan

Subject: [OT]: Compile time tags. (XSLT preprocessing of JSP)

Date:wed, Mar 2001 12:20:45-0800



Translation: Hax at sjtu dot edu dot cn





Here's the idea of separation that I've been thinking about lately ...



I like JSP and custom tags, and that lets us put complex performance (presentation) and

Business logic is abstracted out and hidden behind XML tags. I also like the fast JSP development follow

Ring?? Edit a JSP, press reload in the browser, Ulla!



I've noticed some alternatives to using XSLT to implement JSP tags. such as Cocoon's

The xtp of XSP and resin.



Http://xml.apache.org/cocoon/xsp.html

Http://www.caucho.com/articles/xtp_templates.xtp



It surprises me that, while using standard JSP, we add a set of tools based on X

What will be the SLT "compile-time" label?



What is required? The answer is: We just use the XML-formatted JSP, and in our

The servlet engine applies our XSLT documents to these JSPs before attempting to run them.

XSLT can preprocess specific XML tags to complete simple format conversions or add dynamic code

。 These tags can be given namespaces just like normal JSP custom tags. Got a series.

In the future, we can do more ...



----



Realize:



If the servlet engine does not fully support (JSP) XML format (many of the engines I've tried

So, we can always use the XSLT preprocessing process to put the JSP's XML format

Convert to standard <%=%> format.



Today we can immediately implement XSLT preprocessing, which is the use of our web application

, build (Bulid) all the JSP files with the ant builds system.



However, this interrupts our wonderful fast "edit JSP then reload" development environment. The

If we could integrate the XSLT ' preprocessing ' phase into our JSP compilers, that would

It's cool.



(This paragraph is an example of tomcat/jasper.)



...... I've looked at the source code of Jasper, and it seems to be adding some sort of preprocessing

The configuration of the device is not too difficult. (Of course if there is a Web deployment in the JSP standard

Descriptor to the JSP XSLT preprocessing of the portal (entry), that would be better;--) )



----



Example:



Compile-time labels can only use compile-time variables, although it can output JSP scripts

(scriptlet) An expression. For example, here is an ordinary HTML in a JSP fragment

Examples of forms.



<form action= "something.jsp" method= "Get" >

<P>

The name:

<input type= "text" name= "FirstName"/>

<br/>

Last Name:

<input type= "text" name= "LastName"/>

<br/>

Email

<input type= "text" name= "email"/>

</P>

<br/>

<input type= "Submit" value= "Send" >

<input type= "Reset" >

</FORM>



Using XSLT preprocessing, we can add a small script expression that is based on the shape of the current form

State to fill in the corresponding value in the form field, (and thus become):



<form action= "something.jsp" method= "Get" >

<P>

The name:

<input

Type= "text" Name= "FirstName"

value=´<%= Getformvalue (PageContext, "FirstName")%>´/>

<br/>

Last Name:

<input

Type= "Text" name= "LastName"

value=´<%= Getformvalue (PageContext, "LastName")%>´/>

<br/>

Email

<input

Type= "text" name= "email"

value=´<%= Getformvalue (PageContext, "email")%>´/>



</P>

<br/>

<input type= "Submit" value= "Send" >

<input type= "Reset" >

</FORM>



The function Getformvalue () can use any real Java code to get the form field values, but

To be a custom form pack or simply pull out the parameters of the servlet request.



This means that from the perspective of the Developer (developer)/designer (designer),

JSP maintains ' clear ' and class-HTML form without a small script?? All the clever fill

The charge occurs when we compile the JSP into Java code.



Please note that this also means that we do not need to write JSP for the input label for each type (type)

Custom tags, do not need to have each of the possible attribute values we want to use the corresponding Java

The Bean property. At run time, and no tags are created, there is just a little dynamic on the page ja

The VA code will call Getformvalue (). So, the page will be really efficient.



Note that I am not here to preach the substitution of JSP custom tags, just advocating the use of XSLT in conjunction with the pre

Processing and JSP custom tags, this really elegant way of building web apps ...



Comments?

<James/>

James Strachan



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.