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 Collection API?

Question: Difference between forward and sendRedirect in JSP?

Explain garbage collection?

The output of System.out.println(5>>2) in Java

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

What is the difference between jsp:include page and @ include file?

Interview Question: Write code of any Action Class?

What are all the different scope values for the tag?

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

What is the difference between Session Bean and Entity Bean?

Differentiate between .ear, .jar and .war files.

What are the contents of web module?

Question: How would you go about analyzing performance of an application?

Question: How is the MVC design pattern used in Struts framework?

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

Latest Articles (in Interview)