Reputation: 87
I'm developing a web application.
I've wrriten a jsp, servlet and a bean. On sucessful insertion of records into database I want to redirediect to a new page but response.sendredirect()
reports an error.
The error
The server encountered an internal error () that prevented it from fulfilling this request.
Exception:
java.lang.IllegalStateException
org.apache.catalina.connector.ResponseFacade.sendRedirect(ResponseFacade.java:435)
javax.servlet.http.HttpServletResponseWrapper.sendRedirect(HttpServletResponseWrapper.java:126)
allotmant.seatAllot.processRequest(seatAllot.java:104)
allotmant.seatAllot.doGet(seatAllot.java:134)
javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:390)
Note: The full stack trace of the root cause is available in the Apache Tomcat/6.0.20 logs.
What could be a possible solution?
Upvotes: 1
Views: 3373
Reputation: 72039
Make sure that you're:
sendRedirect()
. For the same reason as #1 if you let the rest of the page render it can fill up the response buffer. Call return
right after your sendRedirect()
to end your servlet, JSP or the like.Upvotes: 1
Reputation: 13841
I think you cannot send a redirect after commiting the headers of the response. When you redirect the header must contain the redirect action. But if you already sent some body content the headers are committed.
So maybe you are sending body content (or mannually commiting the headers) before the redirect.
Upvotes: 1