본문 바로가기

개인 공부방/JSP

내장객체3

▷ 내장 객체의 영역
page 영역 page 기본 객체
하나의 JSP 페이지를 처리할 때 사용되는 영역
request 영역 request 기본 객체
하나의 HTTP 요청을 처리할 때 사용되는 영역
session 영역 session 기본 객체
하나의 웹 브라우저와 관련된 영역
application 영역 application 기본 객체
하나의 웹 어플리케이션과 관련된 영역
세션 내장객체는 ex 로그인 정보를 들 수 있다.
daum에서 로그인을 하고 naver로 넘어갔다가 다시 daum으로 돌아간다면
계속 로그인 상태를 유지하고 있다. 

파일생성 \WebContent\innerObject\setAttribute.jsp 속성 저장하기
파일생성 \WebContent\innerObject\getAttribute.jsp 속성 읽어오기


setAttribute

<%@ page language="java" contentType="text/html; charset=EUC-KR"

    pageEncoding="EUC-KR"%>

<h2> 내장객체 - 내장 객체 영역</h2>


<% 

request.setAttribute("id","aaa"); //변수, 데이터

session.setAttribute("id","bbb");

application.setAttribute("id","ccc");

%>


request : <%=request.getAttribute("id") %><br>

session : <%=session.getAttribute("id") %><br>

application : <%=application.getAttribute("id") %><br>



확인 : <input type="button" value="확인" 

onclick = "javascript:window.location='getAttribute.jsp'">


 


getAttribute

<%@ page language="java" contentType="text/html; charset=EUC-KR"

    pageEncoding="EUC-KR"%>

<h2> 내장객체 - 내장 객체 영역</h2>


request : <%=request.getAttribute("id") %><br>

session : <%=session.getAttribute("id") %><br>

application : <%=application.getAttribute("id") %><br>


 

확인 버튼을 누르면 session과 application은 id정보가 살아 있는데, request는 없어져있다.
 




111209 백업파일

 

'개인 공부방 > JSP' 카테고리의 다른 글

액션태그2  (0) 2011.12.12
액션태그  (0) 2011.12.12
내장객체2  (0) 2011.12.09
declaration 선언문, 내장객체  (0) 2011.12.09
scriptlet, expression  (0) 2011.12.08