title: Display text in textarea using javascript
body: <p>I have used the following code in <strong>index.jsp</strong> to set the value of textarea INPUT_TEXT and INPUT_TEXT2 in a form after extensive processing, wherein the text goes through a servlet, a java class and the preprocessed data then gets returned to the 2nd textarea.</p>
  
  <p>CODE I:</p>
  
  <pre><code>&lt;td&gt;
  &lt;% 
     String txtvalue="";
     if(request.getAttribute("x")!=null){
         txtvalue=request.getAttribute("x").toString();
         System.out.println("txtvalue= "+txtvalue);
   }%&gt;
  
   &lt;textarea id="INPUT_TEXT" name="INPUT_TEXT" style="font-size: 13pt;" rows="15" cols="50"&gt;&lt;%=txtvalue%&gt;&lt;/textarea&gt;
  &lt;/td&gt;
  
  &lt;td&gt;
  &lt;% 
      String txt="";
      if(request.getAttribute("y")!=null){
         txt=request.getAttribute("y").toString();
         System.out.println("txt= "+txt);
   }%&gt;
  
   &lt;textarea id="INPUT_TEXT2" name="INPUT_TEXT2" style="font-size: 13pt;" rows="15" cols="50"&gt;&lt;%=txt%&gt;&lt;/textarea&gt;
   &lt;/td&gt;
  </code></pre>
  
  <p>I have tried using </p>
  
  <p>1)<strong>innerHTML</strong>, </p>
  
  <p>2)setting the value using document.getElementById("INPUT_TEXT") and </p>
  
  <p>3)the present method which I have given in the code I. </p>
  
  <p>Unfortunately, nothing works!</p>
  
  <p><strong>Method 3 (code I) used to work</strong>, but then I had to make some changes in the function that is called after onclick, to make a POST request, which now looks like this:</p>
  
  <p>CODE II</p>
  
  <pre><code>function submitPreprocessForm() {
     var postData=$("#maryWebClient").serializeArray();
     $.ajax({
       url: "preprocess",
       context:this,
       type:"POST",
       dataType:"JSON",
       data:postData,
       contentType: "application/x-www-form-urlencoded;charset=utf-8",
       success: function(response){
       }
   });
  }
  </code></pre>
  
  <p>Now, the txt and txtvalue (Code I) are being printed <strong>only to the NetBeans output console</strong> (correctly, I might add) <strong>but not to the webpage</strong>, which gets reset when I click the submit button. Thus, although the entire internal functioning works perfectly, the only problem is text not being displayed in the respective textareas.
  Kindly help.</p>