首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Java Web开发 >

就差一点了?请大家帮忙啊该怎么解决

2012-01-31 
就差一点了?请大家帮忙啊!还是用户登录验证的问题,我想如果用户名和密码都正确,就跳转到welcome.jsp中,可

就差一点了?请大家帮忙啊!
还是用户登录验证的问题,我想如果用户名和密码都正确,就跳转到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这个页面时候有内容

热点排行