<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=windows-1250">
<meta name="generator" content="PSPad editor, www.pspad.com">
<title></title>
<script type="text/javascript" language="javascript">
var http_request = false;
function makeRequest() {
var url, qs;
var account, pw;
account = document.f1.account.value;
pw = document.f1.pw.value;
http_request = new XMLHttpRequest();
url = "login.jsp";
qs = "account=" + account + "&pw=" + pw;
http_request.onreadystatechange = alertContents;
http_request.open("POST", url, true);
http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
http_request.send(qs);
}
function alertContents() {
var strMsg;
if (http_request.readyState == 4) {
if (http_request.status == 200) {
strMsg=http_request.responseText;
//alert(strMsg);
document.getElementById("disp").innerHTML=strMsg;
} else {
alert('There was a problem with the request.');
}
}
}
</script>
</head>
<body>
<form name="f1">
Account<input type="text" name="account">
Password<input type="password" name="pw">
<input type="button" onclick="makeRequest();">
<a href="javascript:makeRequest()">make a request</a>
<div id="disp"></div>
</form>
</body>
</html>
------------------login.jsp---------------------
<%
String account = request.getParameter("account");
String pw = request.getParameter("pw");
out.println(account);
out.println(pw);
%>
沒有留言:
張貼留言