JSP Declarations – Syntax and Example
A JSP declaration is used to declare variables and methods in a page’s scripting language.
When the scripting language is the Java programming language, variables and methods in JSP declarations become declarations in the JSP page’s servlet class.
JSP Declarations Syntax
1 |
<%! declaration; [ declaration; ]+ ... %> |
You can write XML equivalent of the above syntax as follows:
1 2 3 |
<jsp:declaration> code fragment </jsp:declaration> |
JSP Declarations Example
1 2 3 |
<%! int i = 0; %> <%! int a, b, c; %> <%! Circle a = new Circle(2.0); %> |