// this code snippet sends a request to the login.jsp RequestDispatcher dispatcher = request.getRequestDispatcher("login.jsp"); dispatcher.forward(request, response);
// this code snippet includes a resource in the response // without changing the URL bar of the user's web browser RequestDispatcher dispatcher = request.getRequestDispatcher("header.jsp"); dispatcher.include(request, response);In both examples, the getRequestDispatcher() method is used to obtain a RequestDispatcher object, which is then used to forward or include a resource in the response. The package library used is javax.servlet.http.