[求助]一个连接问题
<html><head>
<base href="<%=basePath%>">
<title>My JSP 'login.jsp' starting page</title>
<meta http-equiv="cache-control" content="no-cache">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head>
<script language="javascript">
var XMLHttpReq = false;
function createXMLHttpRequest(){
if(window.XMLHttpRequest){
XMLHttpReq = new XMLHttpRequest();
}
else if(window.ActiveXObject){
try{
XMLHttpReq = new ActiveXObject(Msxml2.XMLHTTP);
}
catch(e){
try{
XMLHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
}catch(e){}
}
}
}
function sendRequest(url){
createXMLHttpRequest();
XMLHttpReq.open("GET",url,true);
XMLHttpReq.onreadystatechange = processResponse;
XMLHttpReq.send(null);
}
function processResponse(){
if(XMLHttpReq.readyState==4){
if(XMLHttpReq.status==200){
var res = XMLHttpReq.responseXML.getElementsByTagName("res")[0].firstChild.data;
window.alert(res);
}else{
window.alert("页面不正常");
}
}
}
function userCheck(){
var name=document.myform.name.value;
var password = document.myform.password.value;
if(name==""){
window.alert("用户名不能为空");
document.myform.name.focus();
return false;
}else{
sendRequest('login?name='+name+'&password='+ password);
}
}
</script>
<body>
<form name="myform">
帐号:<input name="name" type="text"><p>
密码:<input name="password" type="password"><p>
<input type="button" value="确定" onclick="userCheck()">
</form>
</body>
</html>
JAVAbean里面连接数据库代码 验证name,password
public boolean userCheck(String name,String password){
Session session = null;
List list = null;
try{
session = HibernateSessionFactory.currentSession();
Query query = session.createQuery("from People where name='"+name+"' and password='"+password+"'");
list = query.list();
Iterator it = list.iterator();
if(it.hasNext()){
return true;
}
else{
return false;
}
}
catch(Exception e){
e.printStackTrace();
return false;
}
}
servlet里面的代码
String name = request.getParameter("name");
String password = request.getParameter("password");
System.out.println("name======="+name);
System.out.println("password==="+password);
下面的过不去
Manager ma = new Manager();
System.out.println("gggggggggggg");
boolean bool = ma.userCheck(name,password);
System.out.println("sssssssssss");
System.out.println("bool===="+bool);
执行时候 弹出window.alert("页面不正常");
[此贴子已经被作者于2007-5-27 23:53:04编辑过]