response 객체는 웹 브로우저로 응답할 응답 정보를 가지고 있다.
웹 브로우저에 보내는 응답정보는 HttpServletResponse 객체에 있으며, jsp에서는 response 객체를 사용해 접근한다.
sendRedirect(url);
responseRedirect.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<h2>response 객체 예제 - sendRedirect() 메소드의 사용</h2>
현재 페이지는 <b>responseRedirect.jsp</b> 페이지입니다.
<%response.sendRedirect("responseRedirected.jsp"); %>
</body>
</html>
---------------------------------------------------------
responseRedirected.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<h2>리다이렉트된 페이지 - responseRedirect.jsp</h2>
지금 보시는 페이지는 <b>responseRedirected.jsp</b> 페이지입니다.
</body>
</html>
요청한 페이는 responseRedirect.jsp 인데, 응답은 responseRedirected.jsp 페이지가 한다.
따라서 처리 결과는 responseRedirected.jsp 페이지의 실행 내용만 표시된다.
즉 response.sendRedirect() 메소드가 있는 페이지는 그냥 아무 표시없이 지나간다.
'기존카테고리 > JSP_basic' 카테고리의 다른 글
pageContext 내장객체(냉무) (0) | 2017.06.28 |
---|---|
out 내장객체(냉무) (0) | 2017.06.28 |
request 내장객체 (0) | 2017.06.28 |
톰캣 기반에서 JSP 한글처리 (0) | 2017.06.27 |
while문 (0) | 2017.06.27 |