Declaration Tag


JSP Declarations are used to declare member methods and variables of servlet class.

Syntax:
<%!...>

The code written inside the jsp declaration tag is placed outside the service() method of auto generated servlet i.e. the declaration of jsp declaration tag is placed outside the _jspService() method.

So it doesn't get memory at each request.The jsp declaration tag can declare variables as well as methods.

Following code snippet tells the working of expression tag: