page1源码:
function newDoc() {
window.location.assign("hellow.html")
}
function quzhi() {
var text1 = document.getElementById("name").value; //取得文本框的值
var text2 = document.getElementById("password").value;
alert(text1);//网页提示框
alert(text2);
var myurl = "Test_01" + "?" + "pname=" + text1 + "&password=" + text2;
window.location.assign(encodeURI(myurl))
}
function quzhi2() {
var text1 = document.getElementById("name").value; //
var text2 = document.getElementById("password").value;
var myurl = "hellow.jsp" + "?" + "pname=" + text1 + "&password="+ text2;
window.location.assign(encodeURI(myurl))
}
page2源码:
Insert title herehellow world!
page3源码:
Insert title hereString strName=request.getParameter("pname");
String strPassword=request.getParameter("password");
%>
欢迎您!
您的密码是:
servlet源码: package test;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
* Servlet implementation class Test_01
*/
@WebServlet("/Test_01")
public class Test_01 extends HttpServlet {
private static final long serialVersionUID = 1L;
/**
* @see HttpServlet#HttpServlet()
*/
public Test_01() {
super();
// TODO Auto-generated constructor stub
}
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
response.getWriter().append("Served at: ").append(request.getContextPath());
String strName=request.getParameter("pname");
String strPassword=request.getParameter("password");
System.out.println(strName);
System.out.println(strPassword);
}
/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
doGet(request, response);
}
}
运行后图片