Define Implicit Variables in JSP



Q) What are the implicit variables?

A) Implicit variables are objects that are created by the web container and contain information related to a particular request, page, or application. They are:

–> request
–> response
–> pageContext
–> session
–> application
–> out
–> config
–> page
–> exception

Request:-

It is also an implicit object of class HttpServletRequest class and using this object request parameters can be accessed.

For e.g. in case of retrieval of parameters from last form is as follows:

request.getParameters(“Name”);

Where “Name” is the form element.

Response:-

It is also an implicit object of class HttpServletResponse class and using this object response(sent back to browser) parameters can be modified or set.

For e.g. in case of modifying the HTTP headers you can use this object.

Response.setBufferSize(“50”);

Session:-

Session object is of class HttpSession and used to maintain the session information. It stores the information in Name-Value pair.

For e.g.

session.setValue(“Name”,”Jakes”);
session.setValue(“Age”,”22”);

Application:-

This object belongs to class SevletContext and used to maintain certain information throughout the scope of Application.

For e.g.

Application.setValue(“servername”,”www.myserver.com”);

PageContext:-

This object is of class pageContext and is utilized to access the other implicit objects.

Out:-

This object is instantiated implicitly from JSP Writer class and can be used for displaying anything within delimiters.

For e.g. out.println(“Hi Buddy”);

Page :-

Syntax : < %@ page Language=”Java” extends=”<Class name>” import=”<class> or <package>”  %>

Attributes:
a.     Language = “Java”
b.     Import = “Class”
c.      Buffersize = “”
d.     Scope = “REQUEST/PAGE/SESSION/APPLICATION”
e.     And etc….

Page directive is aimed to define certain attribute of a JSP page for e.g. Language of the page in which the page content should be written , which class to be imported so that it can be used within the JSP page.

Random Posts

  • AWT Interview Questions
  • Define JSP
  • Explain Java takes care of registering the driver
  • Core Java Interview Questions
  • What is Port Number

Post a Comment