Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JSP declaration tag and Scriptlet tag

 
Anoop Krishnan
Ranch Hand
Posts: 163
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Plaese see this simple jsp tags and tell me which one is safe in place of memory usage and in multiple threads
code 1
<%!
String value;
%>
<%
value=request.getParameter("id");
%>
code 2
<%
String value=request.getParameter(id);
%>
[This message has been edited by Anoop Krishnan (edited May 22, 2001).]
 
Dharmesh Chheda
Ranch Hand
Posts: 204
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello anoop
well in code 1, if you open multiple browser windows, then in that case value will hold the latest value .. for example
suppose you declare value as
<%! int value=0 ; %>
and in your code suppose you do
<% value=value+1;%>
then when you open one browser value you will get the value of the variable "value" as 1.

Again if you open another window and re run your code and get the value of the variable "value" then it will not hold one it will hold two.
So in this case the value is persistent
Where as in code 2 the variable "value" will remain local for each particular session.
i hope this clears your doubt .. in case i am wrong correct me or in case you didnt get it ... send a reply
bye
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic