Contents | Prev | Next


Declaration

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

Syntax

<%! declaration; [ declaration; ]+   ... %>

Examples

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

Description

A declaration declares one or more variables or methods that you can use in JavaTM code later in the JSP file. You must declare the variable or method before you use it in the JSP file.

You can declare any number of variables or methods within one declaration element, as long as you end each declaration with a semicolon. The declaration must be valid in the Java programming language.

When you write a declaration in a JSP file, remember these rules:

A declaration has translation unit scope, so it is valid in the JSP page and any of its static include files. A static include file becomes part of the source of the JSP page and is any file included with an <%@ include %> directive or a static file included with a <jsp:include> element. The scope of a declaration does not include dynamic files included with <jsp:include>.

See Also



Contents | Prev | Next

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