PREV NEXT
The JSP declaration scripting begin with <%! and end with %>. Variables declared in JSP declaration may be used in expressions or scriptlets.
The XMP syntax for Jsp declaration is <jsp:declaration>…</jsp:declaration>
syntax for a JSP declaration:
1 |
<%! <i>scripting-language-declaration</i> %> |
The example below illustrates a few variants of JSP declarations.
<%! int i; %> <%! String str=”hello world”; int y=0; %> <%! boolean flag=true; %> <%! Boolean flagClass=new Boolean(true); %> |
All examples above declare variables. They do not print any thing on the web page. A scriptlet or an expression can be used to access variables declared in JSP expression.
Similar to variable declaration, method declaration may also be included within JSP declarations.