JSP.7.4 Scripting Elements


The JSP 1.1 specification has three scripting language elements ”declarations, scriptlets, and expressions. The scripting elements have a "<%"-based syntax as follows :

 <%! this is a declaration %>  <% this is a scriptlet %>  <%= this is an expression %> 

JSP.7.4.1 Declarations

In the XML document corresponding to JSP pages, declarations are represented using the syntax:

 <jsp:declaration> declaration goes here </jsp:declaration> 

For example, the second example from SectionJSP.2.10.1:

 <%! public String f(int i) { if (i<3) return("..."); ... } %> 

is translated using a CDATA statement to avoid having to quote the "<" inside the jsp:declaration .

 <jsp:declaration> <![CDATA[ public String f(int i) { if (i<3) return("..."); } ]]> </jsp:declaration> 
DTD Fragment
 <!ELEMENT jsp:declaration (#PCDATA) > 

JSP.7.4.2 Scriptlets

In the XML document corresponding to JSP pages, scriplets are represented using the syntax:

 <jsp:scriptlet> code fragment goes here </jsp:scriptlet> 
DTD Fragment
 <!ELEMENT jsp:scriptlet (#PCDATA) > 

JSP.7.4.3 Expressions

In the XML document corresponding to JSP pages, expressions are represented using the syntax:

 <jsp:expression> expression goes here </jsp:expression> 
DTD Fragment
 <!ELEMENT jsp:expression (#PCDATA) > 


Java 2 Platform, Enterprise Edition. Platform and Component Specifications
Java 2 Platform, Enterprise Edition: Platform and Component Specifications
ISBN: 0201704560
EAN: 2147483647
Year: 2000
Pages: 399

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net