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();
아래는 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
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();