Login.jsp
4、ndow.alert("请输入用户名");returnfalse;}if(document.form1.pwd.value==""){window.alert("请输入用户密码");returnfalse;}returntrue;}
5、ext"/>
密 码:
Login_ok.jsp<%Stringusername=request.getParameter("username");12[键入文字]usernam
6、e=newString(username.getBytes("ISO8859_1"),"GBK");Stringpwd=request.getParameter("pwd");//out.print(username+pwd);Stringspath="\database\data.mdb";//注意由网站根到文件的路径,用到了转义字符Stringdbpath=application.getRealPath(spath);//转化成物理路径Stringurl="jdbc:odbc:Driver={
7、MicrosoftAccessDriver(*.mdb)};DBQ="+dbpath;Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");Connectionconn=DriverManager.getConnection(url);Statementstmt=conn.createStatement();Stringsql="select*fromadminwhereusername='"+username+"'andpassword='"+pwd+"'";/
8、/out.print(sql);ResultSetrs=stmt.executeQuery(sql);if(rs.next()){session.setAttribute("name",username);out.print("登陆成功!");%>
此文档下载收益归作者所有