본문 바로가기

JSP

익스프레션 언어 requestScope

<%@ 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));

   

    RequestDispatcher dispatcher = request.getRequestDispatcher("ex01_ok.jsp");

    dispatcher.forward(request, response);

 

%>

 

ex01_ok.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>

    1부터 100까지 더한 결과는? <%=request.getAttribute("result") %><br />

    1부터 100까지 더한 결과는? ${result}<br />

    1부터 100까지 더한 결과는? ${requestScope.result}<br />

</body>

</html>




 


'JSP' 카테고리의 다른 글

익스프레션 언어 initParam  (0) 2013.03.21
익스프레션 언어 param paramValues  (0) 2013.03.21
서블릿의 라이프 사이클  (0) 2013.03.21
익셉션 처리 실습  (1) 2013.03.20
URL 재작성 메커니즘  (0) 2013.03.20