title: jsp globals and parameters scope
body: <p>i am really new to java, and jsp. so it is understandable that i cant really understand the scope of parameters
  here is my code:</p>
  
  <pre><code>&lt;%@page contentType="text/html" pageEncoding="UTF-8" %&gt;
  &lt;%!
       String sRony= new String();
       void func() {
          sRony += " - add in func() - ";
      }
  %&gt;
  &lt;%
       if (request.getParameter("ron")!= null){
           sRony = request.getParameter("ron");
           func();
       }
       if (request.getParameter("sleep")!= null){
          Thread.sleep(2000);
       }
  
  %&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;/head&gt;
  &lt;body&gt;
    &lt;%=sRony%&gt;&lt;%= new java.util.Date() %&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>the problem is that this code is not thread safe. if you'll surf to </p>
  
  <pre><code>page.jsp?ron=sleep&amp;sleep=1
  </code></pre>
  
  <p>and at the same time to </p>
  
  <pre><code>page.jsp?ron=no_sleep
  </code></pre>
  
  <p>both page will print the "no_sleep", cause the parameter sRony is global.
  if i'll remove the <code>!</code> from <code>&lt;%!</code> the parameter sRony will not be recognized inside <code>void func()</code>
  i cant figure out how can i declare a parameter that will be per request, and will have the scope inside my function. 
  not sure if my platform is important information, i am working on redhat 5.5 64 bit, glassfish server 3.
  any help ?</p>