Both are statements used to make page transitions from servlet to JSP. It seems that the behavior is different in small places. (Because I have no work experience, I can really feel it.)
forward RequestDispatcher rd = request.getRequestDispatcher("test01.jsp"); rd.forward(request, response);
-------------------- -Need to import javax.servlet.RequestDispatcher -Values can be passed to servlet → JSP using request scope --------------------
redirect //リダイレクト response.sendRedirect("test02.jsp");
-------------------- ・ URL is rewritten -Value cannot be passed to Servlet → JSP using request scope --------------------
Recommended Posts