| Java FAQ | ||
| JSP FAQ | ||
| Servlet FAQ | ||
XyzWs JSP FAQ:
What is difference between page and pageContext in JSP pages?
Printer-friendly version |
Mail this to a friend
|
Advertisement
|
|||||||||
What is difference between
|
| Implicit Object | Class or Interface | Purpose, Function, or Uses |
|---|---|---|
| page | java.lang.Object | Refers to the generated Servlet class.
Since page refers to the generated class and the class implements the Servlet interface, it is a valid cast it to Servlet.
And the page variable could also be cast to JspPage or HttpJspPage since
these two interfaces are derived from the Servlet interface and are implemented by
the generated servlet class. For example,
<%= ((Servlet)page).getServletInfo () %> |
| pageContext | javax.servlet.jsp.PageContext |
Used for storing and retrieving page-related information and sharing objects within the same translation unit and same request. Also used as a convenience class that maintains a table of all the other implicit objects. For example,
public void _jspService (
HttpServletRequest request,
HttpServletResponse response
) throws java.io.IOException, ServletException {
...
try {
...
application = pageContext.getServletContext ();
config = pageContext.getServletConfig ();
session = pageContext.getSession ();
out = pageContext.getOut ();
...
} catch (Throwable t) {
...
} finally {
...
}
}
|