Popular Posts

Monday, June 1, 2009

INTRODUCTION TO JSP DECLARATIVES

Syntax of JSP Declaratives are:

<%!
//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" %>

<html>

<body>

<%!
int cnt=0;
private int getCount(){
//increment cnt and return the value
cnt++;
return cnt;
}
%>

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

<p><%=getCount()%></p>

<p><%=getCount()%></p>

<p><%=getCount()%></p>

<p><%=getCount()%></p>

<p><%=getCount()%></p>

<p><%=getCount()%></p>

</body>

</html>

2 comments:

  1. I am extremely impressed along with your writing abilities, Thanks for this great share.

    ReplyDelete
  2. Nice Post. I simply stumbled upon your blog and wanted to say that I have really enjoyed
    browsing your weblog posts. After all I'll be subscribing on your feed and I am hoping you to
    write again very soon!

    ReplyDelete