JSP Advanced Programming 5

zhaozj2021-02-08  276

Chapter 5 JSP as an XML will show you how to use a standard X M L syntax to write a J S P page. The non-x M l syntax introduced in the previous chapter can find the corresponding X M L format in this chapter. Note that JSP will undoubtedly become more emphasis on XML's grammar format in the future, readers can specify from the latest JSP syntax ---- JavaServer Pages (TM) Specification VE RSIO N1.2 - Public Draft 1 (PD1, also This change trend is found in the public beta. 5.1 Why do you want to use the X m L compatible syntax to architecture J s P? Of course not because X M L is a fashionable thing, but as a J S P which is the X m L document will get a lot of benefits. For example, a standard X M L compatible J S P syntax will help the development of J S P. The X M L syntax of the J s P file makes the content of the J S P file easily organized and managed. You can develop and analyze J S P using X M L development and analysis tools, just need to replace D t d files to upgrade to the latest version of J s P. X M L format uniform syntax is easier to learn and use. 5.2 Syntax 5.2.1 JSP: root elements As the J S P file of the X m L document, there is a element as its root element, which is also a label library (T A G L i b) sets a nomencore. Use the X m L n s attribute in to set the currently used J S P version (via D t D file).

For example: Remainder of Transformed JSP Page 5.2.2 Public identifier as XML The JSP file of the document is recommended to use the following form of document type declaration: 5.3 The general JSP instruction has the following form: <% @ Directive {attr = "value"} *%> can be translated into XML syntax form: 5.3.1 Page instructions as an XML document: Example The following "Page" instruction: <% @ Page Info = "My Latest JSP EXAMPLE V1 .1 "%> The corresponding XML compatible syntax: 5.3.2 Include instructions as an Include instruction for the XML document: Examples of include: <% @ include file = "Copyright.hmtl"%> The corresponding XML compatible syntax: 5.3.1 TAGLIB instruction taglib instructions As mentioned above, is included in the element, is defined in the form of an XMLNS attribute. 5.3.1 Page Indicates that P A g e as the x M1 document is: Examples are as follows. General P A g e refers to: <% @ Page Info = "My LateSt JSP Example V1.1"%> The corresponding X M L compatible syntax: 102 Part 1 JSP Getting Started

5.3.2 Include Indicators as an interlude as an XML document refers to: For example, as follows. General include instruction: <% @ include file = "Copyright.hmtl"%> The corresponding XML compatible syntax: 5.3.3 Taglib instruction Taglib instructions The front is contained in the element, is defined in the form of an XMLNS attribute. 5.4 Script Element J S P's script elements include declaration, script code, and expressions, the following, respectively, the corresponding X M L syntax form. 5.4.1 Declaration of XML form syntax is: Declaration Goes here: <%! Public string f (int i) {IF (i <3) Return (".. "); ...}%> The corresponding XML statement is: The following is the related DTD file clip: 5.4.2 Script code declared XML form syntax for: code fragment goes here < / jsp: scripTlet> The following is the related DTD file segment: 5.4.3 Expression declared XML form syntax: Chapter 5 as XML JS P1 0 3

Expression Goes Here For example: <% = STR i " DATE%> The corresponding XML statement is: string string str =" aasaSDA "; int 1 = 5; java.util.date date = new date (); The following is the associated DTD file clip: 5. How to convert a normal JSP file to An XML document uses the following method to convert a normal JSP file to an XML file: First, add to the text, in this element, make the named prefix "JSP" into the prefix of the standard element in the text. Then, all "<%" is converted to the compatible syntax form of X M L according to the method described above. Next, "T A G L i B" indicates that the "X M L N S" attribute in is used to indicate. Finally, a C D ATA element is established for each of the non-J s p elements. Use Table 5 - 1 to quickly translate a J S P file into an X m L file. Table 5 - 1JSP element XML corresponding element <% @ page ...%> setting <% @ include> setting <% @ include. ..%> <%! ...%> .... <% ...%> .... <% = ....%> .... 5.6 JSP1.1 DTD file here is a DTD file of JSP 1. 1 It can have a complete understanding of the syntax of JSP.

| JSP: Forward | JSP: Usebean | JSP: SetProperty | JSP: GetProperty | JSP: Plugin | JSP: Fallback | JSP: Params | JSP: Param * "> Chapter 5 JS as XML-P1 0 5 106 first part JSP entry

to be continued

转载请注明原文地址:https://www.9cbs.com/read-3318.html

New Post(0)