Can we declare static variables in JSP page.
Answers were Sorted based on User's Feedback
yes
we should do in jsp declarative tag only.if we specify
variables in declaration tag, it belongs to class.
<%! static int i=0; %>
and u can not define static variable in scriptlet(<% %>).
as we know that we can not declare a static variable in a
method.
| Is This Answer Correct ? | 42 Yes | 5 No |
Answer / vijayakumar chinnasamy
In Declaration tag (<%! -- %>), you can able declare the
static variable,class, define methods.
| Is This Answer Correct ? | 23 Yes | 4 No |
Answer / srinu
yes we declare the varible as static in a jsp.we declare the
static varible in the declaration tag.
ex:-
<%! static int a=10;%>
| Is This Answer Correct ? | 12 Yes | 3 No |
What are uses of Hash Code?
Where is core java used?
What is JVM ? use of JVM?
What are the two types of exceptions in java? Which are the differences between them?
can java object be locked down for exclusive use by a given thread? Or what happens when a thread cannot acquire a lock on an object? : Java thread
How the elements are organized in CardLayout?
How list contains works in java?
What is the purpose of sizeof operator?
What are the two categories of data types in the java programming language?
Explain JSP life cycle
What is meant by class loader and how many types are there?
how and when compiler knows that the Java code throws the checked Exception.