• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

retaining the input values

 
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I have the below JSP (product.jsp).

<body>
<html:errors></html:errors>
<h3>Add a product</h3>
<html:form action="/saveProduct">
<table>
<tr>
<td>Product Name:</td>
<td><html:text property="productName"/></td>
</tr>
<tr>
<td>Description:</td>
<td><html:text property="description"/></td>
</tr>
<tr>
<td>Price:</td>
<td><html:text property="price"/></td>
</tr>
<tr>
<td><html:reset/></td>
<td><html:submit>Add Product</html:submit></td>
</tr>
</table>
</html:form>

</body>

In the action form , the validate method has the following logic
if(price.equals("1")){
errors.add("", new ActionError("error.price"));
}

so , in the JSP , when i enter the following value for the fields

Product Name :----> test
Description :-----> testDesc
Price:------->1

and click on the "Add Product" button , since the price file is having the value ="1" , the request gets redirect to the same product.jsp , dispaying the appropriate message( error.price ,define in the property file) in product.jsp.

Now my question is , In case of error , when the request is been redirected to the product.jsp page, why does the JSP retains the form values.

Product Name :----> test
Description :-----> testDesc
Price:------->1

and why does this happen ?

Thanks in advance.
reply
    Bookmark Topic Watch Topic
  • New Topic