看下我的代码,哪里出错?
<%@page import = "java.sql.* "%>
<%@ page import= "java.io.* "%>
<%@ page import = "java.util.* "%>
<%
response.setContentType( "text/html;charset=8859_1 ");
request.setCharacterEncoding( "gb2312 ");
%>
<%
String name = " ";
String userId=request.getParameter( "j_username ");
String userPwd=request.getParameter( "j_password ");
String strSQL= "select * from usermess where userid= ' "+userId+ " 'and userpass= ' "+userPwd+ " ' ";
int count=0;
if(userId.equals( " ")){%>
<script language= "javascript " type= "text/javascript ">
<!--
alert( "您的用户名不能为空! ");
</script>
<%}
else if(userPwd.equals( " ")){%>
<script language= "javascript " type= "text/javascript ">
<!--
alert( "您的密码不能为空! ");
</script>
<%}
else {
try {
Class.forName( "com.microsoft.jdbc.sqlserver.SQLServerDriver ");
Connection conn=DriverManager.getConnection( "jdbc:microsoft:sqlserver://192.168.50.60:1433;DatabaseName=student ", "sa ", "software ");
Statement st=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
ResultSet rs=st.executeQuery(strSQL);
if(rs.next())
{
count++;
System.out.println(count);
}
if(count> 0)
{
String sql= "select * from student where stuid = ' "+userId+ " ' ";
String sql1= "select * from teacher where teaid = ' "+userId+ " ' ";
String sql2= "select * from adminis where adminid = ' "+userId+ " ' ";
rs=st.executeQuery(sql);
if(rs.next())
{session.setAttribute( "loginuser ",userId);
response.sendRedirect( "selectmain.jsp ");//进入学生主系统;
}
else
{
rs=st.executeQuery(sql1);
if(rs.next())
{ session.setAttribute( "loginuser ",userId);
response.sendRedirect( "teachertmain.jsp ");
}
else
{ rs=st.executeQuery(sql2);
if(rs.next())
{
session.setAttribute( "loginuser ",userId);
response.sendRedirect( "adminmain.jsp ");
}
}