Syntax For JSP Declaratives

By: aathishankaran  

Syntax For JSP Declaratives

               While programming in jsp we have to know about the declaratives of jsp. Here the declaratives is explained for jsp files. For the beginners they should know how to declare the variables in jsp program. In this article its explained

           In jsp program mainly three declaratives are used to embed the jsp code into html.

The three declaratives are:

  • <%@ … %>


  • <%! … %>


  • <% … %>


Syntax of JSP Declaratives is:

  //java codes

JSP Declaratives begins with <%! and ends %> with .We can embed any amount of java code in the JSP Declaratives. Variables and functions defined in the declaratives are class level and can be used anywhere in the JSP page.


<%@page contentType="text/html" %>



int cnt=0;
private int getCount(){
//increment cnt and return the value
return cnt;

<p>Values of Cnt are:</p>









This program illustrates how to initialize the variables in jsp program. And the program is shows how to embed the jsp in html program. Here both <@% … %> , <!% … %>, and <% … %> tags are used in this program.

Archived Comments

1. Good
View Tutorial          By: PRANJAL at 2015-08-14 16:38:57

Most Viewed Articles (in JSP )

Latest Articles (in JSP)

Comment on this tutorial