Contents | Prev | Next


Declaration

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

JSP Syntax

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

XML Syntax

<jsp:declaration>	
   declaration; [ declaration; ]+ ...	
</jsp: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 Java code later in the JSP page. You must declare the variable or method before you use it in the JSP page.

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 page, 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 resouce included with a <jsp:include> element. The scope of a declaration does not include dynamic resources included with <jsp:include>.

See Also



Contents | Prev | Next

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