日期:2014-05-18  浏览次数:20734 次

就差一点了?请大家帮忙啊!
还是用户登录验证的问题,我想如果用户名和密码都正确,就跳转到welcome.jsp中,可是用response.sendRedirect( "welcome.jsp ");就是不行啊,当输入用户名和密码时,出现的是空白网页!代码如下:
<%@   page   contentType= "text/html;   charset=gb2312 "   %>

<%@   page   language= "java "   %>

<%@   page   import= "java.sql.* "   %>

<%
//载入数据
String   name   =   request.getParameter( "User ");
String   password   =   request.getParameter( "Password ");

String   driver= "com.mysql.jdbc.Driver "; //驱动程序名
String   url= "jdbc:mysql://localhost:3306/JOB "; //数据库名
String   userid= "root ";                                                           //用户  
String   passwd= "1 ";                                                           //密码  

Class.forName(driver); //载入驱动
try
{
Connection   con=DriverManager.getConnection(url,userid,passwd); //建立数据库连接

Statement   sta   =   con.createStatement(); //建立con下的sta状态

String   sqlstring   =   "select   user_name   from   userTable   where   user_name=   ' "+name+ " '   and   user_password= ' "+password+ " ' "; //完成数据查询语句

ResultSet   rs   =   sta.executeQuery(sqlstring); //建立sta下的rs变量   并执行SQL语句   结果放入rs里
if(   rs.first()   )
{

response.sendRedirect( "welcome.jsp ");
}
rs.close();  
sta.close();  
con.close();  
}
catch(SQLException   el)
{
out.print( "用户名或密码错误! ");
}

%>

------解决方案--------------------
out.print( " <script> window.location= 'welcome.jsp '; </script> ");
------解决方案--------------------
welcome.jsp这个页面时候有内容