웹 서버가 웹 브라우저에게 다른 페이지로 이동하라고 응답하는 기능
#first.jsp
<%@ page language="java" contentType="text/html; charset=EUC-KR"
pageEncoding="EUC-KR"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=EUC-KR">
<title>Insert title here</title>
</head>
<body>
<h1>first.jsp</h1>
<hr>
<%
response.sendRedirect("second.jsp");
%>
</body>
</html>
#second.jsp
<%@ page language="java" contentType="text/html; charset=EUC-KR"
pageEncoding="EUC-KR"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=EUC-KR">
<title>Insert title here</title>
</head>
<body>
<h1>second.jsp</h1>
</body>
</html>
#first.jsp파일을 실행했지만 response.sendRedirect("second.jsp");로 인해 second.jsp로 이동된다.
// response.jsp
<form action="reponse_process2.jsp" method="post">
<p>아이디: <input type="text" name="id">
<p>패스워드: <input type="password" name="pwd">
<input type="submit" value="전송">
//reponse_process2.jsp
<%
String id = request.getParameter("id");
String pwd = request.getParameter("pwd");
if (id.equals("admin") && pwd.equals("1234")) {
response.sendRedirect("success.jsp");
} else {
response.sendRedirect("failed.jsp");
}
%>