Académique Documents
Professionnel Documents
Culture Documents
JSP Objects
An overview
Biswabrata Banerjee
JSP Objects
Built-in JSP Objects and Their Implementation Classes:
Request HttpServletRequest
response HttpServletResponse
out JspWriter
session HttpSession
application ServletContext
pageContext PageContext
config ServletConfig
page Object
exception Throwable
Biswabrata Banerjee
Cont ‘d … JSP Objects
Biswabrata Banerjee
a brief description
The request Object
The request object represents the current request from the browser and is a subclass of the
ServletRequest class. For most current implementations of JSP, the request object is an
instance of HttpServletRequest.
Biswabrata Banerjee
Cont ‘d… a brief description
Biswabrata Banerjee
Request Object
JSP Request Object
Request Object in JSP is used to get the values that the client passes to the
web server during an HTTP request. The request object is used to take the value
from the client’s web browser and pass it to the server. This is performed using an
HTTP request such as: headers, cookies or arguments.
The class or the interface name of the object request is
http.httpservletrequest.
The object request is written: Javax.servlet.http.httpservletrequest.
Request Object
getCookies()
getHeader(String name)
getHeaderNames()
getAttribute(String name)
getAttributeNames()
getMethod()
getParameter(String name)
getParameterNames()
getParameterValues(String name)
getQueryString()
getRequestURI()
getServletPath()
setAttribute(String,Object)
removeAttribute(String)
Response Object
JSP Response Object
The response object denotes the HTTP Response data. The result or the information of
a request is denoted with this object. The response object handles the output of the client.
This contrasts with the request object. The class or the interface name of the response object
is http.HttpServletResponse.
The response object is generally used by cookies. The response object is also used
with HTTP Headers.
Response Object
Methods of response Object: There are numerous methods
available for response object. Some of them are:
setContentType()
addCookie(Cookie cookie)
addHeader(String name, String value)
containsHeader(String name)
setHeader(String name, String value)
sendRedirect(String)
sendError(int status_code)
Session Object
JSP Session Object
Session Object denotes the data associated with a specific session of user. The
class or the interface name of the object session is http.HttpSession.
The object session is written as: Javax.servlet.http.httpsession.
The previous two objects, request and response, are used to pass information
from web browser to server and from server to web browser respectively.The Session
object provides the connection or association between the client and the server. The
main use of Session Objects is to maintain states when there are multiple page
requests.
The main feature of session object is to navigate between multiple pages in a
application where variables are stored for the entire user session. The session objects
do not lose the variables and the value remains for the user’ session. The concept of
maintenance of sessions can be performed by cookies or URL rewriting. A detailed
approach of session handling will be discusses in coming sections.
Session Object
getAttribute(String name)
getAttributeNames
isNew()
getCreationTime
getId
invalidate()
getLastAccessedTime
getMaxInactiveInterval
removeAttribute(String name)
setAttribute(String, object)
Out Object
JSP out object
JSP out object denotes the Output stream in the context of page. The class
or the interface name of the object out is jsp.JspWriter.
The out object is written as: Javax.servlet.jsp.JspWriter
The object that write to the JSP's output stream is defined by the out object.