JAVA/JSP & Servlet
표준 액션(standard action) : forward
zammanza
2013. 3. 22. 13:54
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%
int sum = 0;
for(int cnt = 1 ; cnt <= 100 ; cnt++) sum += cnt;
request.setAttribute("result", new Integer(sum));
%>
<!-- forward 구문은 페이지 가장 끝에 써줌 -->
<jsp:forward page="HundredResult.jsp"></jsp:forward
HundredResult.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>JSP</title>
</head>
<body>
1부터 100까지 더한 값은?? ${result }<br>
</body>
</html>