JSP DECLARATIONS
JSP Syntax: <%! code %>
XML Syntax: <jsp:declaration> code </jsp:declaration>
XML Syntax: <jsp:declaration> code </jsp:declaration>
The third type of Scripting element is the Declaration element. The purpose of a
declaration element is to initialize variables and methods and make them available to
other Declarations, Scriptlets, and Expressions. Variables and methods created within
Declaration elements are effectively global. The syntax of the Declaration element
begins with the standard JSP open tag followed by an exclamation point (<%!).
The Declaration element must be a complete Java statement. It ends with a semicolon,
just as the Scriptlet element does.
declaration element is to initialize variables and methods and make them available to
other Declarations, Scriptlets, and Expressions. Variables and methods created within
Declaration elements are effectively global. The syntax of the Declaration element
begins with the standard JSP open tag followed by an exclamation point (<%!).
The Declaration element must be a complete Java statement. It ends with a semicolon,
just as the Scriptlet element does.
Look at example 3.3. In this example an instance variable named Obj and the
initialization and finalisation methods jspInit and jspDestroy, have been done using
declaration element.
initialization and finalisation methods jspInit and jspDestroy, have been done using
declaration element.
Example 3.3 Declaration element
<%!
private ClasJsp Obj;
public void jspInit()
{
...
}
public void jspDestroy()
{
...
}
%>
private ClasJsp Obj;
public void jspInit()
{
...
}
public void jspDestroy()
{
...
}
%>
No comments:
Post a Comment