JSP
내장객체(Implicit Object)
화이팅하자9
2023. 10. 30. 16:51
sendRedirect() : 웹 서버가 웹 브라우저(클라이언트)에게 이동할 페이지로 이동하라고 지시
<%
response.sendRedirect("http://www.naver.com");
%>
movieURL.html
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<form action="Ex04_url.jsp">
<select name="url">
<option value="naver">네이버</option>
<option value="daum">다음</option>
<option value="google">구글</option>
</select>
<input type="submit">
</form>
</body>
</html>
url.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>
<%
String url = request.getParameter("url");
if(url.equals("naver")){
response.sendRedirect("http://www.naver.com");
}else if(url.equals("daum")){
response.sendRedirect("https://www.daum.net");
}else{
response.sendRedirect("http://www.google.com");
}
%>
</body>
</html>