W3schools - JSP_Implicit
찾으시는 정보가 있으시다면
주제별reference를 이용하시거나
우측 상단에 있는 검색기능을 이용해주세요
Implicit Object
These are the Java object that the JSP container makes available to the developers in each page and the developer can call them directly without being explicitly declared
Object | Description |
---|---|
request | Is the HttpServletRequest object associated with the request |
response | Is the HttpServletResponse object associated with the response to the client |
out | Is the PrintWriter object used to send output to the client |
session | Is the HttpSession object associated with the request |
application | Is the ServletContext object associated with the application context |
config | Is the ServletConfig object associated with the page |
pageContext | Encapsulates use of server-specific features like higher performance JspWriters |
page | Is simply a synonym for this ,and is used to call the methods defined by the translated servlet class |
Exception | Allows the exception data to be accessed by designated JSP |
Request
Is an instance of a javax.servlet.http.HttpServletRequest object
Each time a client requests a page the JSP engine creates a new object to represent that request
The request provides methods to get the HTTP header information including form data, cookies, HTTP methods…
Response
Is an instance of a javax.servlet.http.HttpServletResponse object
Just as the server creates the request object, it also creates an object to represent the response to the client
The response also defines the interfaces that deal with creating new HTTP headers
Through this object the JSP programmer can add new cookies or data stamps, HTTP status codes…
Out
Is an instance of a javax.servlet.jsp.JspWriter object
Is used to send content in a response
The initial JspWriter object is instantiated differently depending on whether the page is buffered or not
Buffering can be easily turned off by using the buffered = ‘false’
attribute of the page directive
The JspWriter object contains most of the same methods as the java.io.PrintWriter class
However, JspWriter has some additional methods designed to deal with buffering
Unlike the PrintWriter object, JspWriter Throws IOExceptions
Method | Description |
---|---|
out.print(dataType dt) | Print a data type value |
out.println(dataType dt) | Print a data type value then terminate the line with new line character |
out.flush() | Flush the stream |
Session
Is an instance of javax.servlet.http.HttpSession
Behaves exactly the same way that session objects behave under Java Servlets
Is used to track client session between client requests
Application
Is direct wrapper around the ServletContext object for the generated Servlet and in reality an instance of a javax.servlet.ServletContext object
Is a representation of the JSP page through its entire lifecycle
Is created when the JSP page is initialized and will be removed when the JSP page is removed by the jspDestory() method
By adding an attribute to application, you can ensure that all JSP files that make up your web application have access to it
Config
Is an instantiation of javax.servlet.ServletConfig
Is a direct wrapper around the ServletConfig object for the generated servlet
Allows the JSP programmer access to the Servlet of JSP engine initialization parameters such as the paths or file locations …
config.getServletName();
It returns the servlet name, which is the string contained in the <servlet-name>
element defined in the WEB-INF\web.xml file
PageContext
Is an instance of a javax.servlet.jsp.PageContext object
Is used to represent the entire JSP page
Is intended as a means to access information about the page while avoiding most of the implementation details
Stores references to the request and response objects for each request
Application, config, session and out object are derived by accessing attributes of this object
Also contains information about the directives issued to the JSP page, including the buffering information, the buffering information, the errorPageURL, and page scope
PageContext class defines several fields, including PAGE_SCOPE, REQUEST_SCOPE, SESSION_SCOPE, and APPLICATION_SCOPE, which identify the four scopes
Also supports more than 40 methods, about half of which are inherited from the javax.servlet.jsp.JspContext class
Page
Is an actual reference to the instance of the page
It can be thought of as an object that represents the entire JSP page
Is really a direct synonym for the this
object
Exception
Is a wrapper containing the exception thrown from the previous page
Is used to generate an appropriate response to the error condition