I have one session level object that is referenced by several wizard jsp pages, each page updating different values on the object. The pages are linked via 'next' and 'previous' buttons. The object is correctly updated when navigating between the pages. However, the last page of the wizard has a 'submit' button. The problem is, the setters for the data on the last page of the wizard are not being called when the submit button is pressed. (but they are when navigating to 'previous')
The only difference between the 'previous'. 'next' and 'submit' buttons is that the 'submit' button goes to a servlet, and the next and previous go to jsp pages.
I fiddled the html so that the submit also went to a jsp page, but it made no difference. I just can't get the last wizard page to store its changes if I click on submit.
Ok, I see what one of my problems is. I need a <setProperty property="*"> on the submit page as well. Is it possible to do this in code in a servlet?
My other problem is this... The spec for JSPs says it will not execute the setter for any value that has been set to "" or null. Why would this be a good thing? If a user sets a form value to empty, I need to know it.
The only solution I can think of to save this is to forward each Next, Previous and Submit through a servlet which uses reflection to go through all the parameters and manually set values and then forward to the 'real' next page. very annoying. Is there a better way?
as you said use servlet as a controller and java class as a model(for business logic) .
coming to your last page submit problem, I will give you a clue ok ?
the clue is *how you are storing the values to session from every page(submitting) ?*
Joined: May 24, 2010
Firstly, I didn't realise the <jsp:setProperty .... property="*"/> needs to go in every destination jsp file, including the submit jsps.
Secondly, the <jsp:setProperty ... property="*"> setting is garbage. It ignores any input set to empty string or null values.
Instead I replaced all the setProperty tags with some third party code do the same reflection trick, but one that does not ignore empty strings and null values.