What is JSP declaration?

By: Karthik Printer Friendly Format    

Answer: JSP Decleratives are the JSP tag used to declare variables. Declaratives are enclosed in the <%! %> tag and ends in semi-colon. You declare variables and functions in the declaration tag and can use anywhere in the JSP. Here is the example of declaratives:

<%@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>

</body>

</html>





Most Viewed Articles (in Interview )

Question: What is a Hidden Comment in JSP?

Interview Question: What about JSTL and JavaServer Faces ?

Interview Question: Is there a particularly good IDE to use with Struts ?

Interview Question: Do ActionForms have to be true JavaBeans?

Interview Question: What is Remote client view?

Interview Question: What are the optional clauses in EJB QL?

Interview Question: What is the difference between EAR, JAR and WAR file?

Interview Question: What is re-entrant. Is session beans reentrant. Is entity beans reentrant?

Interview Question: How many EJB Objects are created for a Bean?

Interview Question: What is deployment descriptor?

Interview Question: What are the call back methods in Entity bean?

Interview Question: What is Message Driven Bean?

Interview Question: What is local interface. How values will be passed?

Interview Question: What is abstract schema?

Interview Question: What is the difference between find and select methods in EJB?

Latest Articles (in Interview)

Comment on this tutorial