Hi,
How we define variable and method in JSP ?
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Satyapriya NayakPosted Oct 12, 2011, 1:21 PM
variable declaration section:- This section can be used in a jsp to declare page scope variables and methods. This section can appear before any html tags.
Syntax:-
<%! Declaration of variables or methods %>
Ex:- <%! int x=100; %>The JSP you write turns into a class definition. All the scriptlets you write are placed inside a single method of this class.
You can also add variable and method declarations to this class. You can then use these variables and methods from your scriptlets and expressions.
To add a declaration, you must use the <%! and %> sequences to enclose your declarations, as shown below.