This week's giveaway is in the Java/Jakarta EE forum. We're giving away four copies of Java EE 8 High Performance and have Romain Manni-Bucau on-line! See pattern. It's packaged as a war file so you can just drop it into a running instance of Tomcat and test it.
Now, you do some logic in the back-end to keep the drop down item the user selected to be selected when the page comes back.
So, if I have other form input text fields, checkboxes and what not, that the user has entered, before I send the request to the server to populate the second drop-down, I guess I have to send them back as well, so that the form does not get "reset". Am I right ?
Every time you submit the form, the selected value from each select list gets send with the rest of the form information.
In that demo, I build the select list option tags in an option and then read all of them as one bean property but you could implement the same logic with JSTL and EL or (dare I say it...) scriptlets in your JSP.
I am thinking of collecting the selected values(including text fields, checkboxes, radio buttons, etc) in a bean( I am using Struts) and placing the bean in request scope after the first form submit. I can use these values in the JSP to pre-popluate the form when it gets displayed the second time.
Is there an easier way ? :-) I will look into JSTL and EL.