JSP-Declaration tag

Declaration tag:

Declaration tag is used to define functions, methods and variables that will be used in Java Server Pages.

Notation of the Declaration tag is shown below:

<%! %>

At the start of Declaration tag one must place <%!  Inside Declaration tag one can declare variables or methods. Declaration tag ends with the notation %>. Also care must be taken to place a semicolon that is ; at the end of each code placed inside Declaration tag.

Syntax of Declaration Tag:

 


<%!                //start of declaration tag
statement1;
statement2;   //variables or methods declaration
……….;
……….;
%>                 //end of declaration tag

Example:

<%!

                 privateint example = 0 ;
privateint test = 5 ;
%>

Leave a Reply

Your email address will not be published. Required fields are marked *