<%@ page contentType="text/html;charset=GB2312"%> <%@ page import="java.sql.*"%> <%@page import="jav
<%@pagecontentType="text/html;charset=GB2312"%><%@pageimport="java.sql.*"%><%@pageimp...
<%@ page contentType="text/html;charset=GB2312"%>
<%@ page import="java.sql.*"%>
<%@page import="javassist.bytecode.stackmap.BasicBlock.Catch"%>
<%@page import="javassist.bytecode.stackmap.BasicBlock.Catch"%>
<html>
<body bgcolor=cyan>
<font size=4>
<form action="" method=post name=form>
<p>
燕山大学里仁学院
<p>
登录号
<input type="text" name="boy" algin="middle" size=26>
<p>
密码
<input type="password" name="girl" algin="middle" size=26>
<p>
<input type="radio" name="cat" value="1" algin="middle" size=26>
学生
<input type="radio" name="cat" value="2" lgin="middle" size=26>
教师
<input type="radio" name="cat" value="3" algin="middle" size=26>
管理员
<p>
<input type="submit" value="登录" name="submit" algin="middle"
size=28>
</form> <%
String s = request.getParameter("cat");
if (s == null) {
return;
}
int type = Integer.valueOf(s);
String name = request.getParameter("boy");
String pwd = request.getParameter("girl");
Connection con = null;
PreparedStatement st = null;
ResultSet rs = null;
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con = DriverManager.getConnection("jdbc:odbc:keshe", "saa",
"saa");
String sql = "select count(*) from userInfo where userName=? and pwd=? and type=?";
st = con.prepareStatement(sql);
st.setString(1, name);
st.setString(2, pwd);
st.setInt(3,type);
rs = st.executeQuery();
if (rs.next()) {
if (type == 1) {
response.sendRedirect("student.jsp");
session.setAttribute("user", name);
}
if (type == 2) {
System.out.println("be 2");
response.sendRedirect("teacher.jsp");
session.setAttribute("user", name);
}
if (type == 3) {
System.out.println("be 3");
response.sendRedirect("guanli.jsp");
session.setAttribute("user", name);
}
}
} catch (Exception e) {
e.getMessage();
} finally {
try {
if (st != null) {
st.close();
}
if (st != null) {
con.close();
}
} catch (Exception e) {
e.printStackTrace();
}
}
%> </font>
</body>
</html>
求改正错误,打不开 啊 展开
<%@ page import="java.sql.*"%>
<%@page import="javassist.bytecode.stackmap.BasicBlock.Catch"%>
<%@page import="javassist.bytecode.stackmap.BasicBlock.Catch"%>
<html>
<body bgcolor=cyan>
<font size=4>
<form action="" method=post name=form>
<p>
燕山大学里仁学院
<p>
登录号
<input type="text" name="boy" algin="middle" size=26>
<p>
密码
<input type="password" name="girl" algin="middle" size=26>
<p>
<input type="radio" name="cat" value="1" algin="middle" size=26>
学生
<input type="radio" name="cat" value="2" lgin="middle" size=26>
教师
<input type="radio" name="cat" value="3" algin="middle" size=26>
管理员
<p>
<input type="submit" value="登录" name="submit" algin="middle"
size=28>
</form> <%
String s = request.getParameter("cat");
if (s == null) {
return;
}
int type = Integer.valueOf(s);
String name = request.getParameter("boy");
String pwd = request.getParameter("girl");
Connection con = null;
PreparedStatement st = null;
ResultSet rs = null;
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con = DriverManager.getConnection("jdbc:odbc:keshe", "saa",
"saa");
String sql = "select count(*) from userInfo where userName=? and pwd=? and type=?";
st = con.prepareStatement(sql);
st.setString(1, name);
st.setString(2, pwd);
st.setInt(3,type);
rs = st.executeQuery();
if (rs.next()) {
if (type == 1) {
response.sendRedirect("student.jsp");
session.setAttribute("user", name);
}
if (type == 2) {
System.out.println("be 2");
response.sendRedirect("teacher.jsp");
session.setAttribute("user", name);
}
if (type == 3) {
System.out.println("be 3");
response.sendRedirect("guanli.jsp");
session.setAttribute("user", name);
}
}
} catch (Exception e) {
e.getMessage();
} finally {
try {
if (st != null) {
st.close();
}
if (st != null) {
con.close();
}
} catch (Exception e) {
e.printStackTrace();
}
}
%> </font>
</body>
</html>
求改正错误,打不开 啊 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询