표현 언어 내장 객체

  1. pageScope

    PageScope에 포함된 속성 값을 참조할 수 있는 객체. 현재 페이지에서만 유효.

  2. requestScope

    RequestScope에 포함된 속성 값을 참조할 수 있는 객체. HTTP 요청 동안 유효.

  3. sessionScope

    SessionScope에 포함된 속성 값을 참조할 수 있는 객체. 사용자가 세션을 유지하는 동안 유효.

  4. applicationScope

    ApplicationScope에 포함된 속성 값을 참조할 수 있는 객체. 애플리케이션 전체에서 유효.

  5. pageContext

    JSP의 내장 객체로, 페이지 컨텍스트에 관련된 여러 가지 정보를 제공.

  6. cookie

    클라이언트 측에서 저장된 쿠키 값을 참조할 수 있는 객체.

1. JSP 내장 객체로 데이터 저장

<%
	int num1 = 1;
	int num2 = 2;

	String str1 = "hello";
	String str2 = "welcome";
	String str3 = "";
	String str4 = null;

	// 표현언어로 출력하기 위해 JSP 내장객체 저장하기
	pageContext.setAttribute("num1", num1);
	request.setAttribute("num2", num2);
	session.setAttribute("str1", str1);
	application.setAttribute("str2", str2);
	request.setAttribute("str3", str3);
	request.setAttribute("str4", str4);
%>

2. 표현식으로 출력

<h4>표현식</h4>
<p>
	num1 : <%= num1 %><br>
	num2 : <%= num2 %><br>
	str1 : <%= str1 %><br>
	str2 : <%= str2 %><br>
	str3 : <%= str3 %><br>
	str4 : <%= str4 %><br>
</p>

3. 표현언어를 사용하여 출력

<h4>표현언어</h4>
<p>
	num1 : ${num1}<br>
	num2 : ${num2}<br>
	str1 : ${str1}<br>
	str2 : ${str2}<br>
	str3 : ${str3}<br>
	str4 : ${str4}<br>
</p>

4. 표현언어 내장객체 출력