select.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>옵션 선택 화면</title>
</head>
<body>
<form action="<%= request.getContextPath() %>/view.jsp">
보고 싶은 페이지 선택:
<select name="code">
	<option value="A">A 페이지</option>
	<option value="B">B 페이지</option>
	<option value="C">C 페이지</option>
</select>
<input type="submit" value="이동">
</form>
</body>
</html>


view.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%
	String code = request.getParameter("code");
	String viewPageURI = null;
	
	if (code.equals("A")) {
		viewPageURI = "/viewModule/a.jsp";
	} else if (code.equals("B")) {
		viewPageURI = "/viewModule/b.jsp";
	} else if (code.equals("C")) {
		viewPageURI = "/viewModule/c.jsp";
	}
%>
<jsp:forward page="<%= viewPageURI %>">
	<jsp:param name="id" value="dragon" />
</jsp:forward>






a.jsp , b.jsp , c.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%
    String code = request.getParameter("code");
    String id = request.getParameter("id");
    %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head><title><%=code %> 페이지</title></head>
<body>

이 페이지는 <b><font size="5"><%=code %></font></b> 입니다.<br>
id 는 <%=id %> 입니다.

</body>
</html>



+ Recent posts