After the apply button is clicked, the data entered by the user disappeared in the text form. How to keep the data appearing on the text form?
It sounds like your form is submitted and the server then re-serves the page identically to the way it was served the first time. Hence the form is devoid of the user's entered values.
If you want the server to re-serve the page with the user's data in place then you need to take measures in your server-side code (JSP/Spring) to re-build the form with the data in it. This is typically done when server-side form-validation fails, in which case you also typically include message(s) on the served page to indicate the errors detected (eg. "A valid email address is required").
action attribute of your
<form> tag determines which server side script (page) is requested when the form is submitted. Thus you can call a different JSP script from the one that originally served the form, or the same script. If no
action attribute is specified or
action="" then the browser assumes that the current page should be re-requested.
method attribute of your
<form> tag controls the way in which the user's form values are packaged in the HTTP request. The two options are
<form action="myscript.jsp" method="get"> <input name="email" /> <br /> <input type="submit" value="Submit"> </form>
Server-side scripts (typically) need to know which
method was used so they know where in the HTTP request to look for the submitted form values.
Whereas I have done some JSP, I don't know the Spring framework. It is possible that some or all of the server-side coding (for (a) form building and (b) acting on the user data) is simplified by Spring, compared to raw JSP.
Edited by Airshow: n/a