액션태그
JSP페이지 내에서 어떤 동작을 하도록 지시하는 태그, 예를 들어 페이지 이동, 페이지 include 등이 있다.
forward 설명 및 사용법
<!-- forward.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>
<h1>forward.jsp 입니다.</h1>
<jsp:forward page="forward_sub.jsp" />
</body>
</html>
<!-- forward_sub.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>
<h1>forward_sub.jsp 입니다.</h1>
</body>
</html>
위 소스에서 forward.jsp 를 실행시키면 결과값으로 forward_sub.jsp 입니다. 이 실행된다. forward.jsp 에서 실행을 시키면 URL은 forward.jsp로 나오고 jsp 내용은 forward_sub.jsp 로 나온다.
param
forward 및 include 태그에 데잍터 전달을 목적으로 사용되는 태그, 이름과 값으로 이루어져 있다.
<!-- forward.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>
<h1>forward.jsp 입니다.</h1>
<jsp:forward page="forward_param.jsp" >
<jsp:param name="id" value="sdddd" />
<jsp:param name="pw" value="1234" />
</jsp:forward>
</body>
</html>
<!-- forward_param.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 id, pw;
%>
<%
id = request.getParameter("id");
pw = request.getParameter("pw");
%>
아이디 : <%= id %> 입니다.
비밀번호 : <%= pw %> 입니다.
</body>
</html>