Abbey Workshop | ||||||||||
As the name implies, JSP declarations are used to declare variables. Declarations are enclosed in a <%! %> tag set and end in a semicolon. Here are some examples:
<%! String aString = "When, in the course"; %><%! private int x=1, y=2; %>
Note that multiple variables can be declared in the same declaration statement.
In addition to declaring variables, methods can also be declared.
For example, a simple addition method might look like this:
<%! public int sum(int x, int y){
return x+y;
}
%>
Here is some sample code to demonstrate declarations:
Download source for: jspDeclare.jsp
Copyright © Abbey Workshop 2006