It's not a secret anymore!
The moose likes Struts and the fly likes retaining the input values Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "retaining the input values" Watch "retaining the input values" New topic

retaining the input values

Prannav Santhosh

Joined: May 09, 2009
Posts: 29

I have the below JSP (product.jsp).

<h3>Add a product</h3>
<html:form action="/saveProduct">
<td>Product Name:</td>
<td><html:text property="productName"/></td>
<td><html:text property="description"/></td>
<td><html:text property="price"/></td>
<td><html:submit>Add Product</html:submit></td>


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

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

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

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

and why does this happen ?

Thanks in advance.
I agree. Here's the link:
subject: retaining the input values
It's not a secret anymore!