Programming/jsp2014. 3. 27. 19:32
jsp의 scope가 있는데
page는 하나의 페이지에 대해서 유효
request는 HTTP request 에 대해서 유효
session은 HTTP session에 대해서 유효
applicatoin은 WAS에 대해서 유효한 값 범위를 지닌다.

조금 다르게 설명을 하면
page는 단일 jsp 파일 하나에 대한
request는 jsp 파일 하나에서 링크로 이어지는 파일까지
session은 웹 브라우저에서 서버로 접속한 세션이 유효한 동안(주로 로그인 인증에 사용)
application은 웹 서버에서 서비스 하는 하나의 전체 홈페이지에 대해서 유효하다.


There are four possible scopes:
  • scope="page" (default scope): The object is accessible only from within the JSP page where it was created. A page-scope object is stored in the implicitpageContext object. The page scope ends when the page stops executing.

    Note that when the user refreshes the page while executing a JSP page, new instances will be created of all page-scope objects.

  • scope="request": The object is accessible from any JSP page servicing the same HTTP request that is serviced by the JSP page that created the object. A request-scope object is stored in the implicit request object. The request scope ends at the conclusion of the HTTP request.

  • scope="session": The object is accessible from any JSP page that is sharing the same HTTP session as the JSP page that created the object. A session-scope object is stored in the implicit session object. The session scope ends when the HTTP session times out or is invalidated.

  • scope="application": The object is accessible from any JSP page that is used in the same Web application as the JSP page that created the object, within any single Java virtual machine. The concept is similar to that of a Java static variable. An application-scope object is stored in the implicitapplication servlet context object. The application scope ends when the application itself terminates, or when the JSP container or servlet container shuts down.

[링크 : http://docs.oracle.com/cd/B14099_19/web.1012/b14014/genlovw.htm

Scope is nothing but lifetime object 

1.page - only in the particular jsp
2.request- only in the jsp to which you forward your request object
3.session- it is available until the session is invalidate(you can access it from any jsp)
4.application-it is available until the web application or server shutdown(you can access it from any jsp).available through whole application
 
[링크 : http://www.coderanch.com/.../certification/Page-Scope-request-Scope-session

[링크 : http://docs.oracle.com/javaee/1.4/api/javax/servlet/jsp/PageContext.html]
[링크 : http://www.java-samples.com/showtutorial.php?tutorialid=1009]

'Programming > jsp' 카테고리의 다른 글

jsp error 페이지 사이즈 제한(IE)  (0) 2014.03.27
jsp buffer  (0) 2014.03.27
JSP에서 euc-kr로 할 경우 저장이 안되는 한글이 있다?  (0) 2014.03.26
JSP 기본 문법  (0) 2014.03.26
웹 서버 및 서비스 개요(java/jsp)  (0) 2014.03.26
Posted by 구차니