Explain JSP Declaration



Jsp Declarations:

As part of Jsp’s we can use declarations using the following Syntax:

<%!

Declarations

%>

As part of the Declarations we can declare the static variables, instance variables and provide the static methods and instance methods

For Ex:

<%! int i=10;
Static int j=10;
public void mone()
{
System.out.println(i);
System.out.println(j);
}
%>

Ex:-2)

<%!
String name = “Mark”;
String date = “28th April, 2004″;
%>

Note: We can’t use implicit variables as part of the methods provided in Declarations as the implicit variables are part of   “_jspservice()”

–> We can’t override the method in the _jspservice

–> We can override the methods in the _jspinit() & _jspdestroy()

We can provide(override) Jsp init,Jsp destroy as part of declarations

Random Posts

  • Session Tracking Example using Servlets
  • Life Cycle of Servlets
  • Difference between session.save() , session.saveOrUpdate() and session.persist()
  • Define Session Tracking
  • Define Session

Post a Comment