title: http request attributes and parameters in jstl, with a servlet
body: <p>I need to do some validation of numbers that come into a servlet1 from a web form.  The process needs to look something like:  </p>
  
  <pre><code>1.) User sends two numbers (t1 and t2) to servlet1 from a web form  
  2.) Servlet 1 validates the numbers by checking:  if (t2-t1)&gt;2 , then t2 = t1 + 2
  3.) The validated numbers are actually sent directly back to the jsp  
  4.) The end user's browser calls a different servlet2 with the output from this servlet1.  
  5.) The end user might repeat this process many times, producing many iterations of customized output  
  </code></pre>
  
  <p>From my research, I think this means:   </p>
  
  <pre><code>a.) setting attributes in servlet1 for t1 and t2 which are sent back to the user's browser with the results of the validation, so that  
  b.) numbers with a valid difference (&lt;=2) can then be sent into servlet2.  
  </code></pre>
  
  <p>My question has to do with how to manage the difference between parameters and attributes.  I think the data starts as parameters in the html input textboxes.  I have jstl code in the textboxes to make sure there is valid data.  But my jstl just works with parameters.  After the first use of the web form by the end user, I think all subsequent iterations will use attributes instead of parameters.  Can anyone show me how to re-write the code that will manage the values of the attributes and parameters, so that the data is always what it should be?  </p>
  
  <p>So far, I have a jsp with an html form that includes input fields with the following format:  </p>
  
  <pre><code>&lt;input type="text" name="t1" value="${empty param.t1 ? '-1' : param.t1}" size="15" /&gt;  
  &lt;input type="text" name="t2" value="${empty param.t2 ? '1' : param.t2}" size="15" /&gt;  
  </code></pre>
  
  <p>The above jsp is the request dispatcher designated by a servlet1, whose doPost method includes something like the following:  </p>
  
  <pre><code>String t1 = request.getParameter("t1");  
  String t2 = request.getParameter("t2");  
  if(((double)t2-(double)t1)&gt;2){  
      t2 = String.valueOf((double)t1 + 2);  
  }  
  request.setAttribute("t1", t1);  
  request.setAttribute("t2", t2);  
  </code></pre>
  
  <p>How do I change this code to maintain the correct data values using attributes?   </p>
  
  <p>Never mind for now that I also need to check to see that the input is actually a number, etc.</p>