JSP Predefined Variables

 

request:

 

·       HttpServletRequest associated with the HTTP request the user made when asking for the .jsp file.

·       Can use all of the methods of this class, in same way did with a Servlet.

o      e.g Can get parameters passed via GET or POST using the getParameter() method.

o      Can get HTTP headers (Cookies, etc)

 

 

response:

·       HttpServletResponse associated with the response to be sent to the client.

·       Can set HTTP status codes, response headers

·       NOTE:  do not retrive an  OutputStream instance to produceoutput to be sent to client….ALREADY exists a predefined variable, called out

 

 

out:

·       PrintWriter instance used to send output back to the client.

·       NOTE:  is buffered (actually an instance of subclass of PrintWriter called JspWriter).

·       Typically, used in scriplets (not in expressions …as these automatically go to the OutputStream!!!)

 

session:

·       HttpSession object associated with the request.

·       First time .jsp file invoke, will translate into a servlet and then invoke the servlet, hence creating a session.

·       Use methods to get information about session.

 

application:

·       ServletContext instance you get in Servlet when invoking getServletConfig().getContext().

·       Can use to store persistent data that ALL Servlets (not just this one) running in the server’s Servlet Engine can share.

·       Uses methods setAttribute() and getAttribute().

·       Recall: your server may or may not be configured to support this.

 

config:

·       ServletConfig instance for the produced Servlet.

 

pageContext:

·       PageContext object associated with page produced by Servlet.

·       NOTE: this class exists only for Servlet’s produced by JSP.

·