Programming Tutorials

What is JSP declaration?

By: Karthik in Interview Tutorials on 2012-06-16  

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> 





Add Comment

* Required information
1000

Comments

No comments yet. Be the first!

Most Viewed Articles (in Interview )

What is Deployment Descriptor?

Explain the user defined Exceptions?

Interview Question: What is difference between EJB 1.1 and EJB 2.0?

Interview Question: What is the difference between ejbCreate() and ejbPostCreate?

Can Entity Beans have no create() methods?

Explain the Polymorphism principle.

What do you understand by JTA and JTS?

Interview Question: What is the difference between JavaBean and EJB?

Interview Question: What is Deployment descriptor?

Interview Question: What is Remote client view?

Interview Question: What is the difference between sessioncontext and entitycontext?

Interview Question: What is lazy loading?

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

Name the containers which uses Border Layout as their default layout?

What is the difference between JTS and JTA?

Latest Articles (in Interview)