checkxszs.jsp

来自「--- --^_^-------------- 广师公寓中心 1.请装上」· JSP 代码 · 共 40 行

JSP
40
字号
<%@page contentType="text/html;charset=gb2312"%>
<%@page import="java.sql.*"%>
<% 
  request.setCharacterEncoding("gb2312");
  String strusername=request.getParameter("textfield1");
  String struserpass=request.getParameter("textfield2");
%>  
<%
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 student where name=trim('"+strusername+"') and xuehao="+struserpass;
ResultSet rs = stmt.executeQuery(sql);  
while(rs.next()){    
session.setAttribute("login1","ok");
session.setAttribute("username",strusername);
 %>
<jsp:forward page="xszs.jsp"/>
<% 
} 
rs.close();  
stmt.close();  
conn.close();
}
catch(Exception ex)
{
out.print(ex);
}
%>
<jsp:include page="loginxszs.jsp"/>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?