<%@ page language="java" contentType="text/html; charset=GBK"%>
<%@ page import="java.sql.*"%>
<html>
<head>
<title>业务处理页面</title>
</head>
<body>
<%
request.setCharacterEncoding("GBK");
String name = request.getParameter("userName");
String pwd = request.getParameter("pwd");
Connection con = null;
Statement stmt = null;
ResultSet rs = null;
try {
Class.forName("com.mysql.jdbc.Driver");
con =DriverManager.getConnection("jdbc:mysql://localhost/news1?user=root&password=123456");
stmt = con.createStatement();
String str = "select * from users where userName='"+name+"' and pwd='"+pwd+"' ";
rs = stmt.executeQuery(str);
if(rs.next()){
if("admin".equals(name))
response.sendRedirect("admin.jsp");
else
response.sendRedirect("index.jsp");
}
else
{
response.sendRedirect("error.jsp");
response.sendRedirect("regist.jsp");
}
}
catch (Exception e) {
e.printStackTrace();
}
%>
</body>
</html>
如上,是用户登录的处理jsp代码,请问哪里出问题了?