Home Tutorial Jsp JSPs : Declarations

 
 

Share on Google+Share on Google+
JSPs : Declarations
Posted on: November 22, 2012 at 12:00 AM
Advertisement
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 ;
} 
%>
Advertisement

Related Tags for JSPs : Declarations :


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: November 22, 2012

Recommend the tutorial

Advertisements Advertisements
 

 

 

DMCA.com