如何将登陆截面和数据库连接呢?
<jsp:useBean id= "alogin " scope= "page " class= "org.pan.web.login " />
<%
String mesg = " ";
if( request.getParameter( "username ")!=null && !request.getParameter( "username ").equals( " ")){
String username =request.getParameter( "username ");
String passwd = request.getParameter( "passwd ");
username = new String(username.getBytes( "ISO8859-1 "));
passwd = new String(passwd.getBytes( "ISO8859-1 "));
alogin.setUsername(username);
alogin.setPasswd(passwd);
if (alogin.excute()){
session.setAttribute( "username ",username);
String userid = Long.toString(alogin.getUserid());
session.setAttribute( "userid ",userid);
response.sendRedirect( "userinfo.jsp ");
%>
<%
}else {
mesg = "登录出错! " ;
}
}
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN ">
<html>
<head>
<base href= " <%=basePath%> ">
<title> Bookstore login.jsp </title>
<meta http-equiv= "pragma " content= "no-cache ">
<meta http-equiv= "cache-control " content= "no-cache ">
<meta http-equiv= "expires " content= "0 ">
<meta http-equiv= "keywords " content= "keyword1,keyword2,keyword3 ">
<meta http-equiv= "description " content= "This is my page ">
<!--
<link rel= "stylesheet " type= "text/css " href= "styles.css ">
-->
<script language= "javascript ">
function checkform() {
if (document.form1.username.value== " " || document.form1.passwd.value== " "){
alert( "用户名或密码为空! ");
return false;
}
return true;
}
</script>
</head>
<body>
<body bgcolor= "#FFCC99 " text= "#000000 ">
<div align= "center ">
<table width= "750 " border= "0 " cellspacing= "1 " cellpadding= "1 ">
<tr>
<td width= "120 " align= "center "> <img src= "images/Img20625.jpg " width= "50 " height= "50 "> <br>
<font color= "#0066cc "> 网络电子书城 </font> <br> </td>
<td align= "center "> <img src= "images/baners2.gif " width= "468 " height= "60 "> </td>