java.lang.IllegalStateException: Cannot call sendRedirect() after the response has been committed

Error message: java.lang.illegalstateexception: cannot call sendredirect() after the response has been committed java.lang.illegalstateexception


Error message parsing: redirection cannot be called after response

Basic overview of Servlet

    determine whether it is necessary to use redirection. If necessary, use redirection. Otherwise, continue the work of servlet

    Cause of error:

      when using retargeting, our page has jumped, and the retargeted code will not be able to perform work. In order to make the jump page unaffected, we add a return after retargeting (most likely) the doget() and dopost() methods in servlet are incomplete. For example, write a doget() method less and delete the super. Doget() and super. Dopost() in the doget() and dopost() methods after rewriting; Here, we can use a request method to receive parameters. For example, the client uses the post or get request to send parameters, and we receive and respond consistently using the get method. At this time, we can add the code dopost (request, response) in the dopost () method check whether the program logic causes multiple jumps

      Note: when we write the redirection path. Redirection supports both the project resources and the resources in the server to use redirection, so the general redirection path is /project resource name/page or servlet to be redirected to or write the relative path directly


Read More: