In JSP, this view is usually processed using javabean to store form values, and then using the jsp: useBean tag. For example, you create the following javabean:
package com.mycompany; public class FormBean { private String var1; private String var2; public void setVar1(String var) { this.var1 = var; } public String getVar1() { return this.var1; } public void setVar2(String var) { this.var2 = var; } public String getVar2() { return this.var2; } }
In your jsp form, you would use the useBean tag, and your form field values would get their bean values:
<jsp:useBean id="formBean" class="com.mycompany.FormBean" scope="session"/> ... ... <input type="text" name="var1" value="<%=formBean.getVar1()%>" />
In your jsp, the form data is sent (then redirected back), you will have the following code that will push the published form data to the bean.
<jsp:useBean id="formBean" class="com.mycompany.FormBean" scope="session"/> <jsp:setProperty name="formBean" property="*"/>
Another option is to simply fill out the form in a session on the save page:
String var1 = request.getParameter("var1"); String var2 = request.getParameter("var2"); session.setAttribute("var1", val1); session.setAttribute("var2", val2); ...
and refer to it in your form (zero check is omitted):
<input type="text" name="var1" value="<%= session.getAttribute("var1") %>" />
John wagenleitner
source share