Hi, I am implementing struts validator in my application and using struts 1.1. I am trying to validate certain conditions in the validate() method of the struts action form. How can we display errors generated for a particular text field beside that field in the JSP? I would really appreciate your help in this regard.
You can using <html:errors/> tag in jsp page to display errors.
Joined: Apr 02, 2004
Hi, Thank you for your reply, but i guess my question has not been interpreted correctly. My problem is that suppose there are 3 text fields in a page say textfield1, textfield2 and textfield3. Then in the validate method of the action form, i do some checks and if there are any errors generated say by textfield1, how would i display the error for that field beside textfield1 in the jsp. In a similar way suppose textfield2 fails the validations, how could i display the error related to textfield2 beside it. The same for textfield3 and so on. I hope i was able to present my question much clearly this time. I would really appreciate any suggestions to tackle this. thanks shaggy
Where ever you want to display the error message in JSP, add the code like this, <html:messages id="errorx" property="Error1"> <bean:write name="errorx"/> </html:messages> where "Error1" is the error that you have added in the validation method. Hope this helps. Praveen.