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 )

Explain the Encapsulation principle.

What is transient variable?

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

What is Deployment Descriptor?

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

Interview Question: Why aren't the Struts tags maintained as part of the Jakarta Taglibs project ?

Interview Question: Where can I get help with Struts?

What is the difference between JTS and JTA?

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

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

What are implicit Objects available to the JSP Page?

Interview Question: Write code of any Action Class?

Interview Question: Why does EJB needs two interfaces(Home and Remote Interface)?

What is Collection API?

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

Latest Articles (in Interview)