Page : 한 페이지(jsp or servlet) 

    ∧

Request : 한 요청이 들어와서 응답이 나갈 때까지

    ∧

Session : Session 객체가 생성되서 소멸될 때까지(여러 요청)

   

Application : 한 어플리케이션이 생성되서 소멸될 때까지

 

● Page

 - JSP : pageContext 내장객체 사용(보통 JSP에서만 사용)

   저장할 때 pageContext객체의 setAttribute(), 읽어올 때 getAttribute() 메소드 사용

   한 페이지에서만 사용되기 때문에 지역변수처럼 사용 됨

 

● Request

 - JSP : request 내장객체, Servlet : HttpServletRequest 객체 사용

   저장할 때 request객체의 setAttribute(), 읽어올 때 getAttribute() 메소드 사용

   forward시 값을 유지할 때

 

● Sesstion

 - JSP : session 내장객체, Servlet : HttpServletRequest의 getSession() 메소드 사용

  저장할 때 sesstion객체의 setAttribute(), 읽어올 때 getAttribute() 메소드 사용

  장바구니처럼 사용자별로 유지가 되어야 할 정보가 있을때

 

● Application

 - JSP : application 내장객체, Servlet : getServletContext() 메소드 사용

  저장할 때 application객체의 setAttribute(), 읽어올 때 getAttribute() 메소드 사용

  모든 클라이언트가 공통으로 사용해야할 값들이 있을때

 

'Web > JSP&Servlet' 카테고리의 다른 글

[JSP] 내장 객체  (0) 2020.07.26
JDBC  (0) 2020.04.24
JSTL(JSP Standard Tag Library)  (0) 2020.04.23
EL(Expression Language)  (0) 2020.04.23
Cookie와 Session  (0) 2020.04.08

+ Recent posts