java.lang.IllegalStateException: Cannot (forward | sendRedirect | create session) after response has been committed

A common misunderstanding among starters is that they think that the call of a forward(), sendRedirect(), or sendError() would magically exit and “jump” out of the method block, hereby ignoring the remnant of the code. For example: This is thus actually not true. They do certainly not behave differently than any other Java methods (expect … Read more

What is the difference between response.sendRedirect() and request.getRequestDispatcher().forward(request,response)

To simply explain the difference, doesn’t prepend the contextpath (refers to the application/module in which the servlet is bundled) but, whereas will prepend the contextpath of the respective application Furthermore, Redirect request is used to redirect to resources to different servers or domains. This transfer of control task is delegated to the browser by the container. That … Read more