0

Possible Duplicate:
java.lang.IllegalStateException: Cannot forward after response has been committed

  <% response.sendRedirect(submit_success);

  %>

I am trying to send redirect to a JSP file after processing my form.

I see execptions in my console -> Cannot forward. Response already committed.Why do I get this error and what should I do to solve this?

[10/1/12 17:35:03:257 EDT] 0000022f servlet E com.ibm.ws.webcontainer.servlet.ServletWrapper service SRVE0068E: Uncaught exception created in one of the service methods of the servlet /SubmitContentProcess.jsp in application dwsecure. Exception created : java.lang.IllegalStateException: Cannot forward. Response already committed. at java.lang.Throwable.<init>(Throwable.java:67) at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.forward(WebAppRequestDispatcher.java:139) at com.ibm._jsp._SubmitContentProcess._jspService(_SubmitContentProcess.java:233) at com.ibm.ws.jsp.runtime.HttpJspBase.service(HttpJspBase.java:99) at javax.servlet.http.HttpServlet.service(HttpServlet.java:831) at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1657) at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:939) at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:502) at com.ibm.ws.webcontainer.servlet.ServletWrapperImpl.handleRequest(ServletWrapperImpl.java:17

Community
  • 1
  • 1
smiley
  • 491
  • 3
  • 14
  • 36
  • 6
    Don't abuse a JSP as controller. That logic belongs in a servlet. – BalusC Oct 01 '12 at 21:50
  • Don't try to forward after sending a response? – user207421 Oct 01 '12 at 22:00
  • I am trying to convert the servlet code to JSP scriptlet. What can I do instead? When I submit it should redirect me to success page. – smiley Oct 01 '12 at 22:37
  • 2
    Why are you converting a servlet to a JSP? That's a step backwards and falls under "using the wrong tool for the job". – BalusC Oct 01 '12 at 23:09
  • We have a code freeze where we can't deploy class files. While JSP can be easily deployed without getting approvals. I am actually coding a similar page like the existing one.To ensure my code is working, I am rewriting the servelet to a jsp. – smiley Oct 01 '12 at 23:18
  • I am writing a JSP (form) which calls another jsp to process on form submit. It has to redirect to success jsp after the submission is successful. – smiley Oct 01 '12 at 23:22
  • Well, This was a management decision anyways. I would prefer to get some suggestions/answers from you :) – smiley Oct 03 '12 at 06:37

0 Answers0