일반 서블릿 내장 객체 (Implicit Object)

황제낙엽 2004.11.12 14:23 조회 수 : 473 추천:206

sitelink1  
sitelink2  
sitelink3  
sitelink4  
sitelink5  
sitelink6  
Implicit Object (내장 객체)

아래는 9가지 내부 객체(implicit object)에 대해서 나타낸다.

  1. page (javax.servlet.jsp.HttpJspPage)
  2. config (javax.servlet.jsp.servletConfig)
  3. request (javax.servlet.http.HttpservletRequest)
  4. reponse (javax.servlet.http.HttpservletReponse)
  5. out (javax.servlet.jsp.JspWriter)
  6. session (javax.servlet.http.HttpSession)
  7. application (javax.servlet.servletContext)
  8. pageContext (javax.servlet.jsp.PageContext)
  9. exception (java.lang.Throwable)

여기에서 page객체와 config객체는 서블릿 관련 내부 객체이다.

이것은 JSP문서를 서블릿으로 구현할 때 사용이 된다.

page 객체는 앞에서 언급한 page지시자를 사용하면 되는것으로 알고 있으므로 설명하지는 않겠다.

1. 입출력 관련 : Request, Response, Out
2. 서블릿 관련 : Page, Config
3. 환경정보 관련 : Session, Application, PageContext
4. 예외정보 관련 : Exception



각 SCOPE별 사용 예제


In this example, when the Counter bean is instantiated, it is placed within
the servlet context, and can be accessed by any JSP or servlet that belongs
to the application (i.e. belongs to the same servlet context).

The servlet equivalent of the above useBean action is:

foo.Counter counter =
(foo.Counter)getServletContext().getAttribute("counter");
if (counter == null) {
  counter = new foo.Counter();
  getServletContext().setAttribute("counter", counter);
}



------------------------------------------------------------------------

In this example, when the Counter bean is instantiated, it is placed within
the current session, and can be accessed by any JSP or servlet during a
subsequent request by the current user.

The servlet equivalent of the above useBean action is:

HttpSession session = request.getSession(true);
foo.Counter counter = (foo.Counter)session.getValue("counter");
if (counter == null) {
  counter = new foo.Counter();
  session.putValue("counter", counter);
}



------------------------------------------------------------------------

In this example, when the Counter bean is instantiated, it is placed within
the current request object, and can be accessed by any JSP or servlet during
a the same request; e.g., if a RequestDispatcher is used, or if
or sends the request to another servlet or JSP.

The servlet equivalent of the above useBean action is:

foo.Counter counter = (foo.Counter)request.getAttribute("counter");
if (counter == null) {
  counter = new foo.Counter();
  request.setAttribute("counter", counter);
}



------------------------------------------------------------------------

In this example the Counter bean is instantiated as a local variable inside
the JSP method. It is impossible to share a page scope variable with another
JSP or Servlet.

The servlet equivalent of the above useBean action is:

foo.Counter counter = new foo.Counter();
번호 제목 글쓴이 날짜 조회 수
63 J2SE 5.0 Tiger 에 관해서 황제낙엽 2006.02.16 375
62 Building an eBay Rich Client using the XUI Framework 황제낙엽 2006.01.13 369
61 Vector 와 ArrayList의 차이 황제낙엽 2006.02.15 479
60 Using RSS in JSP pages (Informa Project) 황제낙엽 2006.01.10 40802
59 달력만들기 황제낙엽 2005.12.22 636
58 Velocity의 GenericTools 에 있는 DateTool 황제낙엽 2005.12.21 452
57 StringTokenizer 예제소스 황제낙엽 2005.12.21 613
56 유니코드로 된 파일 이름을 인터넷 익스플로러에서 저장하는 방법 황제낙엽 2005.12.01 543
55 Date 클래스와 Calendar 클래스 사이에... 황제낙엽 2005.12.14 337
54 한글처리2 황제낙엽 2005.12.01 424
53 한글처리1 황제낙엽 2005.10.20 533
52 유니코드 관련 유틸 클래스 황제낙엽 2005.07.16 633
51 음력 계산 로직 황제낙엽 2005.07.16 448
» 서블릿 내장 객체 (Implicit Object) 황제낙엽 2004.11.12 473
49 java.text.SimpleDateFormat 클래스를 이용하여 java.util.Date 의 객체 생성시 초기화하기 황제낙엽 2004.10.03 538
48 서블릿에서 페이지출력 황제낙엽 2004.09.30 377
47 Web Server Page작성시 한글처리를 위한 참고사항 (자바서비스넷 링크문서) 황제낙엽 2004.05.27 558
46 서버페이지의 처리시 charset 설정 황제낙엽 2004.05.27 564
45 서버페이지 호출시 파라미터의 한글처리 황제낙엽 2004.05.27 361
44 forward & sendRedirect 황제낙엽 2004.03.09 545