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 )

Interview Question: Where can I get a copy of Struts?

What is J2EE Connector architecture?

Interview Question: Is it possible to share an HttpSession between a JSP and EJB? What happens when I change a value in the HttpSession from inside an EJB?

Interview Question: What is the difference between Message Driven Beans and Stateless Session beans?

Interview Question: Do ActionForms have to be true JavaBeans?

Interview Question: What is Remote client view?

Explain the different forms of Polymorphism.

Interview Question: What about JSTL and JavaServer Faces ?

What are Access Specifiers available in Java?

What do you understand by JSP Actions?

Interview Question: What is abstract schema?

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

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

Interview Question: What is Struts Validator Framework?

Interview Question: Write code of any Action Class?

Latest Articles (in Interview)