Can we declare static variables in JSP page.

Answers were Sorted based on User's Feedback



Can we declare static variables in JSP page...

Answer / rajender

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

Can we declare static variables in JSP page...

Answer / vijayakumar chinnasamy

In Declaration tag (<%! -- %>), you can able declare the
static variable,class, define methods.

Is This Answer Correct ?    23 Yes 4 No

Can we declare static variables in JSP page...

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

Post New Answer

More Core Java Interview Questions

Why unicode is important?

0 Answers  


Why string objects are immutable in java?

0 Answers  


What is classpath?

0 Answers  


Is int a class in java?

0 Answers  


What is the public method modifier?

0 Answers  






What are the Static and Dynamic Variables? Differentiate them.

0 Answers   CGI,


How do you escape a string?

0 Answers  


Why use string handling in Java?

0 Answers   HCL,


How do you remove all elements from an arraylist in java?

0 Answers  


public class AboutStrings{ public static void main(String args[]){ String s1="hello"; String s2="hel"; String s3="lo"; String s4=s2+s3; //to know the hash codes of s1,s4. System.out.println(s1.hashCode()); System.out.println(s4.hashCode()); // these two s1 and s4 are having same hashcodes. if(s1==s4){ System.out.println("s1 and s4 are same."); }else System.out.println("s1 and s4 are not same."); } } Somebody told me that, == operator compares references of the objects. In the above example even though s1 and s4 are refering to same object(having same hash codes), it is printing s1 and s4 are not same. Can anybody explain in detail why it is behaving like this? Thanks in Advance RavuriVinod

4 Answers   TCS,


What is mysql driver class name?

0 Answers  


How to invoke external process in java.

0 Answers  


Categories