Jsp-implicit object
Introduction:
Implicit object means pre-defined object. Jsp provide some implicit object. Already jsp developer has created some object for later use. This object is called implicit object.
What is oops?
Object Oriented Programming is main feature of java. In java every task is performed within the method. The method is defined within the class. To call this method, using object. So we must create object of this class and use new operator to create object. Using object, we call method. So it is called object oriented programming.
A). Create class
B). Create method
C). Create object in main class
D). Using object, call the method.
But java developer feels that some object are needed often. So they created class and created object themselves. So we don’t need to create object separately. We just use object name.method name. Here we keep it in mind which method is used for which purpose.
Note:
How to call pre defined method?
All predefined method are included within the class. And that class also is included into the package. So we import the package and create the object of the class. Using created object, we can call the method.
For example, we want to get the time. First we import java.util package. Because the method getHours() is included in java.util package. So we include java.util package and create the object for Date class.
Java.util.Date
getHours()
import java.util.*;
class Example
{
public void display()
{
Date d=new Date();
System.out.println(d.getHours());
}
}
class Examplemain
{
public static void main(String args[])
{
Example e=new Example();
e.display();
}
}
Here we import java.util and create object for Date class and using object of the Date class to call the getHours() method.
But if we use predefined boject, there is no need to create object to call method.
They defined eight pre defined object.
1). request |
2). response |
3). session |
4). out |
5). application |
6). config |
7). pageContext |
8). page |
Implicit Object | type |
request | javax.servlet.http.HttpServletRequest(For Http) javax.servlet.ServletRequest(Not Http) |
It is used to retrieve data submitted along with a request. |
Implicit Object | type |
response | javax.servlet.http.HttpServletResponse(For Http) javax.servlet.ServletResponse(Not Http) |
It is used to send an HTML output to the client. |
Implicit Object | type |
session | javax.servlet.http.HttpSession |
· session object is associated with request object. |
Implicit Object | type |
out | javax.servlet.jsp.JspWriter |
· Used for writing data to the output buffer · Buffer size can be adjusted or can be turned off using buffer attribute in page directive · out object is used in scriptlets |
Implicit Object | type |
exception | java.lang.Throwable |
· refer to the runtime exception |
Implicit Object | type |
page | java.lang.Object |
|
Implicit Object | type |
pageContext | Javax.servlet.jsp.PageContext |
· represent the PageContext object for this page. |
Implicit Object | type |
config | Javax.servlet.ServletConfig |
· Contain servlet configuration data |
Implicit Object | type |
application | javax.servlet.ServletContext |
· It is used to share information among all usrs of a currently active application |