I am trying to make a struts (version <2) app, and am inserting an employee record.
All I want to do is to a) display an alert saying employee created (and clear out the emp details fields) b) validation for the emp details (which I plan to do in the validate method).
Any and every example I search, all of them are returning a success or a failure from the action class, in terms of a new jsp.
I could definitely redirect to the same jsp and have an if/else block and check for some flag I can set in the session. But, is this the only way to go about it ?
What could I do ?
You can use Ajax to insert the record to database and return true/false based on the insert status.
Other way is to keep a variable in your bean class and set it based on the result of the insert status and once the same jsp is reloaded, call a method on load of the page where in you can check the status of that hidden variable and display alert and clear out the fields. This is the same method which you described in your post.
These are the only 2 ways that come to mind right now.