1. too many session variables impact performance and scalablity, you can use hidden input controls, or cookies
2. use DHTML + Javascript to create/delete records, when the user clicks 返回修改按钮, submit the form, then use the choice you made to save the records
2. use DHTML + Javascript to create/delete records, when the user clicks 返回修改按钮, submit the form, then use the choice you made to save the records
客户端的输入文件 /1.jsp
<%@ taglib uri='WEB-INF/tlds/html.tld' prefix='html' %>
...
<table>
<tr><td><input type='text' size=15 name='firstName' value='<html:requestParameter property="firstName"/>'></td></tr>
<tr><td><input type='text' size=15 name='lastName' value='<html:requestParameter property="lastName"/>'></td></tr>
...
</table>新建包含requestParameter标记的标记库 /WEB-INF/tlds/html.tld<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE taglib PUBLIC
"-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.1//EN"
"http://java.sun.com/j2ee/dtds/web-jsptaglibrary_1_1.dtd"><taglib>
<tlibversion>1.0</tlibversion>
<jspversion>1.1</jspversion>
<shortname>Sun Microsystems Press Tag Library</shortname>
<info>This tag library has a single counter tag</info> <tag>
<name>requestParameter</name>
<tagclass>tags.GetRequestParameterTag</tagclass>
<bodycontent>empty</bodycontent>
<attribute>
<name>property</name>
<required>true</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
</tag>
</taglib>标记处理程序 /WEB-INF/classes/tags/GetRequestParameterTag.java
package tags;
import javax.servlet.ServletRequest;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.TagSupport;
public class GetRequestParameterTag extends TagSupport{
private String property;
public void setProperty(String property){
this.property=property;
}
public int doStartTag() throws JspException{
ServletRequest req=pageContext.getRequest();
String value=req.getParameter(property);
try{
pageContext.getOut().print(value==null?"":value);
}catch(java.io.IOException e)
{System.err.println(e.getMessage());}
return SKIP_BODY;
}
}利用标记处理程序有很多好处,我就不介绍了,你可找相关资料查阅。
good luck