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