Hi,
We do that with two servlets and two jsp pages.
One for the customer list and one for the customer detail.
-----CustomerListServlet----
actionId="display" means query for data and forward to jsp.
actionId="delete" means delete requested customer(s) and redirect to URL for CustomerListServlet with actionId "display".
----- customer_list.jsp -----
View link - URL to CustomerDetailServlet with actionId="display", pageMode="view", customerId=...
Edit link - URL to CustomerDetailServlet with actionId="display", pageMode="edit", customerId=...
Delete button - Submit with actionId="delete", pageMode="view", list of customers to delete.
Add link - URL to AddCustomerServlet with actionId="display" and customerId=(null).
---------CustomerDetailServlet------------
actionId="display", customerId not null, means query for the customer data and forward to the jsp using the pageMode specified in the request.
actionId="display, customerId null, means create a default customer bean and forward to the jsp using pageMode="edit".
actionId="save", valid customer information, means save the update and Redirect to a URL for the CustomerDetailServlet with actionId="display", pageMode="view", customerId=...
------customer_detail.jsp-------------
fields are either input or plain html based on the pageMode
String or "edit" or "view".
Save button - Submit with actionId="save", list of data to save. Button does not show for "view" mode.
Cancel button - URL for CustomerListServlet with actionId="display".
------------------------------------
Things I don't like about this approach.
--Query for the data repeatedly, evey time a page loads or reloads. However, it keeps the application stateless and the data "fresher". If your database server performance can keep up...
--Lots of servlets with similar code. An abstract servlet class does help keep the duplicate code down to a dull roar, but the servlets end up being very similar. Because of this I believe Struts is a good suggestion.