Q:

java.lang.IllegalStateException: PWC1227: Cannot forward after response has been committed.....why it was comming?

to add some row data into a table, affter submmiting the button i have to show the details(data) in the next page of that regarding table. when i am using RequestDispather class i am getting the java.lang.IllegalStateException:........ it was also comming while using response.sendRedirect("View.jsp");..... i am sending the code what i used in my page.
if(msg.equals("Values Added")){
                 RequestDispatcher rd = request.getRequestDispatcher("View.jsp");
                 rd.forward(request, response);
                 }

(OR)
if(msg.equals("Values Added")){
                 response.sendRedirect("View.jsp");
                 }

A:

JSP is part of the response. You cannot change the response like that from inside a JSP. It's too late then. This piece of code should have been placed in a servlet class.
Change your form to submit to a servlet instead:
<form action="servleturl" method="post">

Create a servlet class which is mapped on an url-pattern of /servleturl/* and move all the Java code you have there in JSP into the doPost() method.
See also:

Servlets tag info page - mini tutorial and useful links
How to avoid Java code in JSP files

A:

The following is not true per se:
"You cannot change the response like that from inside a JSP. It's too late then."
Just place your postback check and redirect before the html tag in your jsp...then everything will be fine.
So:
<% if(msg.equals("Values Added")){
             response.sendRedirect("View.jsp");
             } %>

<html > ... </html> 

