📄 checklogin1.jsp
字号:
<%@page contentType="text/html;charset=gb2312"%>
<%@page import="java.sql.*"%>
<%
String strusername=request.getParameter("textfield2");
String struserpass=request.getParameter("textfield3");
%>
<html>
<body background="images/background.gif">
<%
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}
catch(ClassNotFoundException e)
{
out.print(e);
}try{
String strDirPath=application.getRealPath(request.getRequestURI());
strDirPath=strDirPath.substring(0,strDirPath.lastIndexOf('\\'))+"\\";
strDirPath=application.getRealPath("ODBC/gongyu.mdb");
String url = "jdbc:odbc:driver={Microsoft Access Driver (*.mdb)};DBQ="+strDirPath;
Connection conn = DriverManager.getConnection(url);
Statement stmt = conn.createStatement();
String sql="SELECT * FROM main where name='"+strusername+"' and pass='"+struserpass+"'";
ResultSet rs = stmt.executeQuery(sql);
while(rs.next()){
session.setAttribute("login","ok");
session.setAttribute("username",strusername);
session.setAttribute("userpass",struserpass);
%>
<jsp:forward page="zs.jsp"/>
<%
}
rs.close();
stmt.close();
conn.close();
}
catch(Exception ex)
{
out.print(ex);
}
%>
<%
out.println("<Script>");
out.println("alert('用户名或密码错误!')");
out.println("</Script>");
%>
<div align="center"><jsp:include page="login1.jsp"/></div>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -