[Top] [Prev] [Next] [Bottom]


Declares a variable or method valid in the page scripting language.

JSP Syntax

<%! declarations %>


<%! int i = 0; %>
<%! int a, b, c; %>
<%! Circle a = new Circle(2.0); %>


A declaration declares one or more variables or methods for use later in the JSP source file.

A declaration must contain at least one complete declarative statement. You can declare any number of variables or methods within one declaration tag, as long as they are separated by semicolons. The declaration must be valid in the scripting language used in the JSP file. In JSP 1.0, you must use the JavaTM programming language for scripting, and declarations must conform to the Java Language Specification.

When you use the Java programming language for scripting, remember these rules:

In general, a declaration has page scope, so it is valid in scriptlets, expressions, and other declarations within the same JSP source file. But if a JSP file includes other files, the rules of scope become a bit trickier. The rules of scope for declarations are described below:

See Also

[Top] [Prev] [Next] [Bottom]

Copyright © 1999, Sun Microsystems, Inc. All rights reserved.