In this Section, we will discuss about declaration of variables & method in JSP using declaration tags.
Using Declaration Tag, you can declare any number of variables & methods , as long as you end each declaration with a semicolon. The declaration must be valid in the Java programming language.
Point to remember before Declaration :
Note :- The scope of the declaration is JSP page means
it is valid only in JSP page & any of its static included files.The dynamic
files included with
<jsp:include>, does not comes inside the scope of
<%! declaration; [ declaration; ]+ ... %>
<%@page import="java.util.*" %>
<!-- Declaring variable & method -->
Date theDate =new Date();
System.out.println("In getDate() method" ); return theDate;
Hello! The time is now<%= getDate() %>
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.