JSPs : Declarations


 

JSPs : Declarations

This section contains the description of Declarations which is one of JSPs components.

This section contains the description of Declarations which is one of JSPs components.

JSPs : Declarations

This section contains the description of Declarations which is one of JSPs components.

Declarations :

This tag is used for defining the functions and variables to be used in the JSP. This element of JSPs contains the java variables and methods which you can call in expression block of JSP page. Declarations are defined by using <%! and %> tags. Whatever you declare within these tags will be visible to the rest of the page.

In declaration tags you can declare one or more variables at the class level. Initialization process can be customized to allow the JSP page to read persistent configuration data, initialize resources, and perform any other one-time activities. For that you can override the jspInit method of the JspPage interface.

Syntax - 

 <%! declaration(s) %>

Example :  In this example we are declaring both a variable and a method.

<%!
private static int PI = 3.1415;
private int function(int a)
{
return a ;
} 
%>

Ads