We use Struts framework in our application that has lot of JSP pages. What ever the user enters in those pages are saved in the session and at the last page, the user has an option to save everything to the database.
Now, we have to provide a Save button on every page, so that the user can save the data entered in that screen (and in the previous screens) to the database.
What is the best approach to acheive this? I was thinking of creating a separate page containing this Save button and including it in all the pages (lets call it as Save.jsp). But there are 2 issues
If I'm understanding you correctly, the real problem is that before you had only one submit button that says essentially "Continue to the next page without saving to the database", and now you want to keep this function and also add another that says "save this page and all previous in the database and return to this page".
This assumes you have already written a validate() function that returns true if the page passes the validations, and false if it doesn't.
The save button onclick event would call submitForm('save.do') and the next button onclick event would call submitForm('next.do').
If you want to put the new submit button in jsp include file, that's fine, but the function would be the same either way.
Since you want the save.do action to return to the page that called it, you will probably want to put a hidden field on each page identifying the calling page, so that the logic in your save action can forward to the appropriate page.