private void actionDo(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
System.out.println("actionDo");
request.setAttribute("id", "abcde");
request.setAttribute("pw", "12345");
RequestDispatcher dispatcher = request.getRequestDispatcher("/dispacherJsp.jsp");
dispatcher.forward(request, response);
}
id : <%= request.getAttribute("id") %> <br />
pw : <%= request.getAttribute("pw") %>
출력 결과 : (요청객체를 위임받아 전달값이 있다.)
id : abcde
pw : 12345
private void actionDo(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
System.out.println("actionDo");
String id = (String)request.getAttribute("id");
String pw = (String)request.getAttribute("pw");
response.setContentType("text/html; charset=EUC-KR");
PrintWriter writer = response.getWriter();
writer.print("<html><head></head><body>");
writer.print("RequestObj2" + "<hr />");
writer.print("id : " + id + "<br />");
writer.print("pw : " + pw);
writer.print("</body></html>");
}
<%
request.setAttribute("id", "abcde");
request.setAttribute("pw", "12345");
response.sendRedirect("../RequestObj2");
%>
출력 결과 : (요청객체를 위임받지 않고 새로운 객체를 생성해서 전달값이 없다.)
id : null
pw : null