Difference between include() and forward() methods of RequestDispatcher in Servlert

What is the difference between include and forward methods of RequestDispatcher interface is one of the frequently asked Servlet questions from Java EE interviews and we'll see how you can answer this question on your interview. You get the RequestDispatcher reference either from ServletContext or ServletRequest interface and even though both include() and forward() method allow a Servlet to interact with another servlet, main difference between include() and forward is that include() method is used to load the contents of the specified resource (could be a Servlet, JSP, or static resource e.g. HTML files) directly into the Servlet's response, as if it is part of the calling Servlet. On the other hand, forward() method is used for server side redirection, where an HTTP request for one servlet is routed to another resource (Servlet, JSP file or HTML file) for processing.
Read more »