The javax.servlet.RequestDispathcer interface can forward a request to another resource.
Getting a RequestDispatcher object
ServletRequest#getRequestDispatcher(String path)
Specify the relative path.
If the relative path starts with "/", it's relative to the context root.
e.g. /Sample1
e.g. Sample1
ServletContext#getRequestDispatcher(String path)
Specify the relative path to the context root.
e.g. /Sample1
void forward(ServletRequest request, ServletResponse response)
Forwards a request to the specified resource.
void include(ServletRequest request, ServletResponse response)
Includes the specified resource in the response.
The forward method forwards a request or includes content directly on the server side, which is different to the HttpServletResponse#sendRedirect method.