日期:2014-05-17 浏览次数:20691 次
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
request.getRequestDispatcher("/result1.jsp").forward(request, response);
}
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<script type="text/javascript">
function openBpage(){
window.open("/TestServlet/openpage", '_blank');
}
</script>
<body>
<form name="indexPage" method="POST">
<H1>this A Page</H1>
<a>click the button to get the number</a>
<input type="button" value="open B page" onclick="openBpage();">
<input type="hidden" name="testNumber" value="123">
</form>
</body>
</html>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<script type="text/javascript">
function loadparent() {
document.fo.MyNumber.value = opener.document.indexPage.testNumber.value;
}
</script>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body onload="loadparent();">
<form name="fo">
<H1>this B Page</H1>
MyNumber: <input type="text" name="MyNumber" value="">
</form>
</body>
</html>
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
<display-name>testweb1</display-name>
<servlet>
<servlet-name>openpage</servlet-name>
<servlet-class>org.testweb1.OpenPage</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>openpage</servlet-name>
<url-pattern>/openpage</url-pattern>
</servlet-mapping>
</web-app>