我在jsp應用程序中重定向時遇到了一些問題。通過servlet重定向JSP
我重定向的方法是這樣的:
public static void redirectUrl(String url,HttpServletRequest request,HttpServletResponse response) throws ServletException,IOException
{
request.getSession().getServletContext().getRequestDispatcher("/" + url).forward(request,response);
}
當我開始在本地主機上所有應用程序工作正常,但是當我部署在服務器上它與此異常崩潰:
Servlet error
java.lang.IllegalStateException: Response has already been committed
at com.evermind[Oracle Application Server Containers for J2EE 10g (10.1.2.3.0)].server.http.EvermindHttpServletResponse.resetBuffer(EvermindHttpServletResponse.java:1933)
at com.evermind[Oracle Application Server Containers for J2EE 10g (10.1.2.3.0)].server.http.ServletRequestDispatcher.forward(ServletRequestDispatcher.java:221)
at app.framework.request.Controller.doPost(Controller.java:50)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at com.evermind[Oracle Application Server Containers for J2EE 10g (10.1.2.3.0)].server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:835)
at com.evermind[Oracle Application Server Containers for J2EE 10g (10.1.2.3.0)].server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:341)
at com.evermind[Oracle Application Server Containers for J2EE 10g (10.1.2.3.0)].server.http.ServletRequestDispatcher.forward(ServletRequestDispatcher.java:230)
at com.evermind[Oracle Application Server Containers for J2EE 10g (10.1.2.3.0)].server.http.GetParametersRequestDispatcher.forward(GetParametersRequestDispatcher.java:257)
我在每次重定向調用後放置return語句,但它不起作用。
有人能告訴我爲什麼嗎?
在此先感謝。
你能提供代碼,告訴您如何調用從其他地方這種方法嗎?謝謝 – 2012-07-26 08:58:57