j2ee: Implicit Objects and their Scope [12/20] ![]() ![]() ![]() |
Objects can be manipulated in JSP.
Objects exist in different scopes:
Remember, and object created inside a method would only have scope in that
method as well. In Java, we also limit scope by using the { }
An object with a given scope is accessible to pages that are in the same scope as the page where the object was created. (more on this later)
Certain objects are created implicitly for each page by the container:
All of these are predefined and can be used inside your JSP.
request
response
pageContext
session
application
out
config
page
exception - for error pages only
request
javax.servlet.ServletRequest
(i.e.
javax.servlet.http.HttpServletRequest
)
response
javax.servlet.ServletResponse
(i.e. javax.servlet.http.HttpServletResponse
)
pageContext
getOut(), getException(), getPage() getRequest(),
getResponse(), getSession(), getServletConfig()
and
getServletContext().
setAttribute(), getAttribute(), findAttribute(),
removeAttribute(), getAttributesScope()
and
getAttributeNamesInScope().
forward(), include(),
and
handlePageException().
session
javax.servlet.http.HttpSession
)application
getServletConfig().getContext()
in a servletout
javax.servlet.jsp.JspWriter
config
javax.servlet.ServletConfig
that you would get
from calling getServletConfig()
in a servletpage
java.lang.Object
exception
java.lang.Throwable