title: How to set the value returned from servlet to a Textbox in a JSP page
body: <p>I have created a simple web service to add two numbers and executed the same using a console program in Java which worked fine. I wish to convert it to a web application, where I have three text boxes, two for the user input and third for the result. When the user clicks the add button, the web service is invoked and result is to be displayed in the textbox. </p>
  
  <p>The <code>index.jsp</code> is as follows:</p>
  
  <pre><code>&lt;%@ page language="java" contentType="text/html; charset=ISO-8859-1"
      pageEncoding="ISO-8859-1"%&gt;
  &lt;%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %&gt;    
  &lt;!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"&gt;
  &lt;title&gt;Simple Web Service&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;form method="get" action="ServiceCall"&gt;
          &lt;input type="text" name="x" /&gt;
          &lt;input type="text" name="y" /&gt;
          &lt;input type="text" name="sum" disabled /&gt;
          &lt;button type="submit"&gt;Add&lt;/button&gt;
      &lt;/form&gt;
      &lt;c:if test="${not empty result}"&gt;
          &lt;h1&gt;${result}&lt;/h1&gt;
      &lt;/c:if&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Here the result will be displayed on a separate line with h1 heading. I would like to put the value of <code>${result}</code> in the sum text field <code>&lt;input type="text" name="sum" disabled /&gt;</code>. </p>
  
  <p>Referring to this <a href="https://stackoverflow.com/questions/18159480/how-to-set-value-of-input-box-in-jsp">setting value of input textbox in jsp</a>, I found <code>value='&lt;%=${result}%&gt;' /&gt;</code> will do it. But the <code>&lt;c:if&gt;..&lt;/c:if&gt;</code> are to be included as well. How do I achieve this?</p>