JSP provides certain implicit objects, based on the Servlet API. These objects are access using standard
variables, and are automatically available for use in our JSP without writing any extra code.
The implicit objects available in a JSP page are:
    • request, response
    • page, session, application
    • pageContext
    • config
    • out
    • exception

The request Object
The request object has request scope, and is an instance of the javax.servlet.ServletRequest class.
It encapsulates the request coming from the Client and being processed by the JSP. It is passed to the JSP by the
container as a parameter of the _jspService( ) method. It has request scope.

The response object
The response object has page scope, and is an instance of javax.servlet.ServletResponse
It encapsulates the response generated by the JSP to be send back to the client in response to the request. It is
generated by the container and passed to the JSP as a parameter to the _jspService( ) method, where it is
modified by the JSP. It is legal to set HTTP status code and headers in the JSP page once output has been send
to the client, as JSP output streams are buffered by default.

The pageContext objects
The pageContext provides a single point of access to many of the page attribute and is convenient place to put
shared data within the page. It is of type javax.servlet.jsp.pageContext and has page scope.

The session object
The session object represents the session created for the requesting client. Session are created automatically,
and a new session is available even when there is no incoming session (unless, of course, you have used a
session=”false” attribute in the page directive, in which case this variable will not be available).
The session object is of type javax.servlet.http.HttpSession and has session scope.

The application object
The application object represents the servlet context, obtained from the servlet configuration object. It is of type
javax.servlet.ServletContext and has application scope.

The out object
The out object is the object that writes into the output stream to the client. To make the response object useful,
this is a buffered version of the javax.servlet.jsp.JspWriter.The buffer size can be adjusted by the
buffer attribute of the page directive.

The config object
The config is the ServletConfig for the JSP page and has page scope. It is of type
javax.servlet.ServletConfig.

The page object
The page object is an instance of the page’s implementation servlet class that is processing the current request.
It is of type java.lang.Object, and has page scope. The page object can be thought of as a synonym to
this within the page.


Scope In JSP

The scope of JSP objects- JavaBeans and implicit objects – is critical, as it defines the how long, and from
which JSP pages, the object will be available.
    • Page Scope
    • Request Scope
    • Session Scope
    • Application Scope


Page Scope
An object with page scope is bound to javax.servlet.jsp.PageContext.
The object is placed in the PageContext object for as long as the page is responding to the current request.
An object with this scope can be accessed by invoking the getAttribute( ) method on the implicit page Context
object. The object is created and destroyed for each client request to the page.
This is the default scope for objects used with the <jsp:useBean> action.

Request Scope
Request scope means that the object is bound to the javax.servlet.ServletRequest, and can be
accessed by invoking the getAttribute( ) method on the implicit request object.
The object is distinct for every client request. The object reference is available as long as the HttpRequest object
exists, even if the request is forwarded to different page, or if the <jsp:include> action is used.

Session Scope

An object with session scope is bound to the javax.servlet.jsp.PageContext, and can be
accessed by invoking getValue( ) method on the implicit session object. The generated servlet relies on binding
the object to the HttpSession using the setAttribute(String key, Object value) method. The object is different for
every client, and is available as long as the client’s session is valid.

Application Scope

Application Scope means that the object is bound to the javax.servlet.ServletContext. An object
with this scope can be accessed by invoking the getAttribute( ) method on implicit application object.
This is the most persistence scope. When accessing application variables, take care your code is thread safe.
Application variables are often populated on application startup, and read – only thereafter.