# How to declare an object of a class using JSP declarations?

JSPJava 8Object Oriented ProgrammingProgramming

A declaration declares one or more variables or methods that you can use in Java code later in the JSP file. You must declare the variable or method before you use it in the JSP file.

Following is the syntax for JSP Declarations −

<%! declaration; [ declaration; ]+ ... %>

You can write the XML equivalent of the above syntax as follows −

<jsp:declaration>
code fragment
</jsp:declaration>

Following is an example of Object declaration in JSP Declarations −

<%! Circle a = new Circle(2.0); %>
Published on 20-Mar-2019 10:27:23