servlet页面转向暂停--------急.在线待
我是在一个jsp(login.jsp)息..转向servlet(logincheck)判断合法性...并当用户密码正确的时候转另一个负责显示所有用户的servlet(listmain)........
----------------------
当输入正确有用户和密码转向负责显示所有用户的listmain时..代码似乎暂停.浏览器状态栏的进度条在一半的时候停止..页面停留在登陆页面(login.jsp)....?如果改成转向其它页面..可以正常跳转?
-------------------------------listmain.java的代码如下--
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import DB.DbTool;
import java.sql.*;
public class listmain extends HttpServlet
{
public void doGet(HttpServletRequest request,HttpServletResponse response)throws
IOException,
ServletException {
response.setContentType( "text/html;charset=utf-8 ");
PrintWriter out=response.getWriter();
out.println( " <html> <head> ");
out.println( " <title> 数据列表 </title> </head> ");
out.println( " <table> ");
out.println( " <tr> <td> 重新登陆 <td> ");
out.println( " <td colspan= '3 '> </td> ");
out.println( " <td> 添加用户 </td> </tr> ");
out.println( " <tr> <td> 用户编号 </td> ");
out.println( " <td> 用户名称 </td> ");
out.println( " <td> 用户密码 </td> ");
out.println( " <td colspan= '2 '> 操--作 </td> </tr> ; ");
DbTool list=new DbTool();
ResultSet rs=null;
String sqlstr= "select * from login ";
rs=list.getrs(sqlstr);
//rs.beforeFirst();
int count=0;
try
{
while(rs.next())
{
rs.last();
count=rs.getRow();//获得查询行的总数
rs.beforeFirst();
}
//输出数据---------------
for(int i=1;i <=count;i++)
{
out.println( " <tr> <td> <%=rs.getString( 'UserId ')%> </td> ");
out.println( " <td> <%=rs.getString( 'UserName ')%> </td> ");
out.println( " <td> <a href= 'delete?id= <%rs.getString( 'UserId ')%> '> 修改 </a> </td> ");
out.println( " <td> <a href= 'modfiy?id= <%rs.getString( 'UserId ')%> '> 删除 </a> </td> ");
out.println( " <td> <%=rs.getString( 'UserPwd ')%> </td> </tr> ");
}
rs.close();
//输出数据;;;;;
}
catch (
SQLException ee)
{
}
out.println( " </table> ");
out.println( " </body> </html> ");
out.close();
}
public void doPost(HttpServletRequest request,HttpServletResponse response)throws IOException,ServletException
{
doGet(request,response);
}
}
------解决方案--------------------如果rs不为空,这就是死循环