<%! this is a declaration %> 
<% this is a scriptlet %> 
<%= this is an expression %>
White space is optional after  <%! ,  <% , and  <%= , and before  %> .
The equivalent XML elements for these scripting elements are described in Section 7.4.
2.10.1
Declarations
Declarations are used to declare variables and methods in the scripting language used in a 
JSP page. A declaration should be a complete declarative statement, or sequence thereof, 
according to the syntax of the scripting language specified.
Declarations do not produce any output into the current 
out
 stream.
Declarations are initialized when the JSP page is initialized and are made available to other 
declarations, scriptlets, and expressions.
Examples
For example, the first declaration below declares an integer, and initializes it to zero; while 
the second declaration declares a method.
<%! int i = 0; %>
<%! public String f(int i) { if (i<3) return( ... ); ... } %>
Syntax
<%! 
declaration(s)
 %>
2.10.2
Scriptlets
Scriptlets can contain any code fragments that are valid for the scripting language specified 
in the 
language
 directive. Whether the code fragment is legal depends on the details of the 
scripting language; see Chapter 4.
Scriptlets are executed at request processing time. Whether or not they produce any output 
into the 
out
 stream depends on the actual code in the scriptlet. Scriptlets can have side 
effects, modifying the objects visible in them.
55
JavaServer Pages 1.1 Specification  
November 30, 1999




JSP Web Hosting JavaServer Pages Specifications JSP Hosting




 
TotalRoute.net Business web hosting division of Vision Web Hosting Inc. All rights reserved.