title: javascript inside java/jsp code
body: <p>i've written the javascript code inside </p>
  
  <p><strong>myjsp.jsp</strong></p>
  
  <pre><code>&lt;%
  try {
      String id=request.getParameter("id");
  %&gt;
      &lt;script type="text/javascript" &gt;
          alert("TRY"+ &lt;%=id %&gt;);
          document.getElementById("mytext").readonly="readonly";
      &lt;/script&gt;
  &lt;%
  } catch (Exception e) {
  %&gt;
      &lt;script type="text/javascript" &gt;
          alert("CATCH"+&lt;%=e%&gt;);
      &lt;/script&gt;
  &lt;%
  }
  %&gt;
  </code></pre>
  
  <p>So, whenever value will be passed into the <code>id</code> it'll show the value of <code>id</code> into the alertbox and also it'll make the textbox whose id is <strong>mytext</strong> will become disable.</p>
  
  <p>So, when i'm executing the <strong>myjsp.jsp</strong> page without passing the parameter it shows the output as <strong>TRYnull</strong>, but when i'm passing the value into <code>id</code> then it's not showing anything, not even alertbox. Any idea !!</p>
  
  <p>My jsp page</p>
  
  <pre><code>&lt;html&gt;
      &lt;head&gt;
          &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8"&gt;
          &lt;title&gt;JSP Page&lt;/title&gt;
      &lt;/head&gt;
      &lt;body&gt;
          &lt;h1&gt;Hello World!&lt;/h1&gt;
         &lt;%
  try {
      String id=request.getParameter("id");
  %&gt;
      &lt;script type="text/javascript" &gt;
          alert("TRY"+ "&lt;%=id %&gt;");
          alert(document.getElementById("mytext"));
      &lt;/script&gt;
  &lt;%
  } catch (Exception e) {
  %&gt;
      &lt;script type="text/javascript" &gt;
          alert("CATCH"+&lt;%=e%&gt;);
      &lt;/script&gt;
  &lt;%
  }
  %&gt;
  
              &lt;input id="mytext" name="mytext" /&gt;
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>