jsp页面中使用iframe导致连接被重置、重复执行两次的奇怪问题!
先说一下环境winxp, jdk1.4.2, resin 3.0.3
在一个jsp页面中加了一个iframe,嵌入了另一个页面,当嵌入的页面执行form的提交动作时,连接经常的被重置,又重复执行了一次,提示:com.caucho.vfs.ClientDisconnectException: connection reset by peer。(tomcat下执行连个提示都没有,直接又重复执行了两次)。
两个页面的源代码如下,请大家研究一下,到底是怎么回事,怎么解决???
第一个文件: 1.jsp
<%@ page contentType="text/html; charset=gb2312" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>主页面</title>
<script>
function pagereset(){
document.all.mainFrame.src = "2.jsp";
}
function ManagerButton(i){
document.form1.runType.value = i;
document.all.mainFrame.src = "2.jsp?runType=" + document.form1.runType.value;
}
</script>
</head>
<body>
<h1>主页面</h1>
<form name="form1" method="post">
<table width="95%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td><input type="button" name="add" value="添加" onClick="ManagerButton(1)">
<input type="hidden" name="runType" value=""></td>
</tr>
<tr>
<td><hr></td>
</tr>
<tr>
<td valign="top">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td valign="top"> <IFRAME name=mainFrame src="2.jsp" frameBorder=0
noResize width="100%" height="200" allowTransparency></IFRAME>
</td>
</tr>
</table></td>
</tr>
<tr>
<td><hr></td>
</tr>
</table>
</form>
</body>
</html>
第二个文件: 2.jsp
<%@ page contentType="text/html; charset=GBK" %>
<%@ page import = "java.sql.*"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>
添加页面
</title>
<%!
int runType;
String Name;
public int StringToInt(String str){
if(str==null||str=="")
return -1;
else
return Integer.parseInt(str);
}
%>
<%
runType = StringToInt(request.getParameter("runType"));
Name = request.getParameter("Name");
%>
<script>
function ss(i){
form = document.form2;
form.runType.value = i;
form.submit();
}
</script>
</head>
<body bgcolor="#ffffff">
<form name=form2>
<input type=hidden name=runType value=<%=runType%>>
<%switch(runType){
case 1:
%>
<table border="0" cellpadding="0" cellspacing="0">
<tr>
<td height="18" colspan=2 align=center><h1>添加页面</h1></td>
</tr>
<tr>
<td nowrap>名称:</td>
<td><input type=input name=Name value="" size=15></td>
</tr>
<tr>
<td colspan=2 ><input type="submit" value="添加" onclick="ss(11)">
<input type="reset" value="重写" ></td>
</tr>
</table>
<%
break;
case 11:
%>
<table width=80% align=center>
<%System.out.println(Name);%>
<tr>
<td ><h1>添加 <%=Name%> 成功</h1></td>
</tr>
<tr><td><h2>请查看控制台的输出窗口中连接是否被重置,Name被输出了两次!!</h2></td></tr>
<tr>
<td >
<input type=button name=close value="继续添加" onclick="document.location.href='2.jsp?runType=1'">
<input type=button name=close value="页面复位" onclick="parent.pagereset()">
</td>
</tr>
</table>
<%
break;
default:
%>
<h1>请大家看看这个问题到底是什么原因造成的!怎么改?</h1>
<%
}
%>
</form>
</body>
</html>