Java/Servlets/RequestDispatcher
Use RequestDispatcher to forward user to a jsp page
import java.io.IOException;
import java.util.List;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class BookListXMLJSPServlet extends HttpServlet {
protected void service(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
List bookList = BookListFactory.INSTANCE;
request.setAttribute("bookList", bookList);
RequestDispatcher dispatcher = getServletContext()
.getRequestDispatcher("/booklist1.jsp");
dispatcher.include(request, response);
}
}