As I understand it, when you wrap a servlet with a RequestDispatcher object and use the forward() method, you delegate that servlet to handle the request and produce the response. But what exactly is happening when you include an html page as an argument for getRequestDispatcher()?
This is from oracle:
RequestDispatcher getRequestDispatcher(java.lang.String path) Returns a RequestDispatcher object that acts as a wrapper for the resource located at the given path. A RequestDispatcher object can be used to forward a request to the resource or to include the resource in a response.
So where in the http response is this resource contained, how does the page receiving the response know to navigate to this page? And if the request was sent with AJAX, will the rest of the JS within that page be executed before redirecting to the new page? (i.e. If I'm writing a script that stores data from the response in a session, will this execute before the client navigates to another page?)