部分代码: if(rs.next())
{ ........
}
else
{
System.out.print("logbean.error");
response.sendRedirect("index.html");//去掉这一句不会报错
}
}
}
catch(SQLException exp)
{
System.out.print(exp);
}
RequestDispatcher rd = request.getRequestDispatcher("main.html");
rd.forward(request, response);
}
错误提示:java.lang.IllegalStateException: Cannot forward after response has been committed
javabean.login.doPost(login.java:89)
javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
请问怎么解决,我的想法是如果if的条件成立 就跳转到main.html 否则 就跳转到index.html
{ ........
}
else
{
System.out.print("logbean.error");
response.sendRedirect("index.html");//去掉这一句不会报错
}
}
}
catch(SQLException exp)
{
System.out.print(exp);
}
RequestDispatcher rd = request.getRequestDispatcher("main.html");
rd.forward(request, response);
}
错误提示:java.lang.IllegalStateException: Cannot forward after response has been committed
javabean.login.doPost(login.java:89)
javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
请问怎么解决,我的想法是如果if的条件成立 就跳转到main.html 否则 就跳转到index.html
else
{
System.out.print("logbean.error");
response.sendRedirect("index.html");//去掉这一句不会报错
return;
}