<%! declaration tag problem to be careful - clarification
Consider 96 for teh percentage sign in the description below throughout
<code>
<%! int i = 5; %>
<%int j=5;%>
<%i++; %>
<%j++; %>
<%out.println(" i value " + i); %>
<%out.println(" j value " + j); %>
</code>
The output of the above program when we run in browser will be
i value 6
j value 6
Now if we refresh the browser the output is
i value 7
j value 6
Then if we open another browser and execute the program the output is
i value 8
j value 6
from above we note that the value of i increases while value of j is always 6.
Here j is a local variable while i is instance variable. But even if we open in new
browser and run the program the value of i always increases.
Actually in the documentation it is given that for declarations we have to use <%! tag
But here when we use that it seems that variable "i" becomes static as the value increases
even if we open in new browsers.
That would cause problem in the general code with does not have isThreadSafe=false
in the page directive.
Like it is very likely that if we do not use isThreadSafe=false and use <%! for declaring
variables then if say person A and person B logs on simultaneously then the value
of i of person A may get printed for person B and if person A refreshs his browser then
the value of i which got incremented for person B may again get incrmented for person A and get
displayed.
I hope many developers use <%! tag for declaring the varaibles do all know that it becomes shareable among
all users of the program if isThreadSafe=false is not used
Is my thinking is correct. Is there a way to say that all jsp pages to have isThreadSafe=false instead
of specifying that in each jsp page in page directive
Thanks to all

