본문 바로가기
Spring/JSP

[JSP] selectFrom으로 페이지 이동

by JJH0100 2022. 11. 18.
728x90
반응형

selectFrom.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>원하는 사이트를 선택해주세요</h2>
	<form name="site" action="site.jsp">
		<select name="site">
			<option value="http://www.naver.com">네이버</option>
			<option value="http://imbe.co.kr">MBC</option>
			<option value="http://www.daum.net">다음</option>			
			<option value="http://www.nate.com">네이트</option>			
		</select>
		
		<input type="submit" value="제출">
	</form>
</body>
</html>

site.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>
<% response.sendRedirect(request.getParameter("site")); %>
</body>
</html>
728x90
반응형

'Spring > JSP' 카테고리의 다른 글

[JSP] 쿠키(Cookie)  (0) 2022.11.21
[JPS] 쿠키(Cookie)와 세션(Session)  (0) 2022.11.21
[JSP] jsp:forward와 jsp:param를 사용한 로그인  (0) 2022.11.18
[JSP] 내장 객체의 영역  (0) 2022.11.18
[JSP] 입출력 관련 객체  (0) 2022.11.17

댓글