In the previous post we have seen how jsp is compiled into a servlet. But when the code is compiled
by a java compiler it will generate an error indicating that we are using a variable "j" without
declaring it.
According to the jsp specification we can use the following variables as part of the scriptlets
without declaring the variables in the jsp page. These variables are called as "well known variables"
or "implicit variables". There are 9 implicit variables:
- pageContext
- session
- request
- response
- application
- config
- out
- page
- exception
pageContext is a convenient class which provides the methods like forward, include,
getSession, getServletConfig, getServletContext, getRequest, getResponse, setAttribute,
getAttribute, removeAttribute etc.
request object is an instance of a java class that implements the
javax.servlet.http.HttpServletRequest interface. The request object can be used to
get header information, parameters, attributes etc.
response object is an instance of a java class that implements the
javax.servlet.http.HttpServletResponse interface. Using the "response" object we can
set the response content type, add cookie and redirect the response.
session object is an instance of a java class that implements the
javax.servlet.http.HttpSession interface. Using the "session" object we can store
session state for a single user.
application object is an instance of a java class that implements the
javax.servlet.ServletContext interface. It gives facility for a JSP page to obtain and
set information about the web application in which it is running.
out object is an instance of the javax.servlet.jsp.JspWriter class.
Using the "out" object we can send some content to the client. In other words we can
write the output content.
No comments:
Post a Comment