JSP PageContext Implicit Object

In this tutorial you will learn about the JSP PageContext Implicit Object and its application with practical example.

JSP PageContext Implicit Object

This is the instance of javax.servlet.jsp.PageContext object. The pageContext instance provides access to all namespace associated with JSP pages .

The PageContext class is an abstract class which defines some fields, including APPLICATION_SCOPE, SESSION_SCOPE, REQUEST_SCOPE,PAGE_SCOPE Which identify the four scope and also defines and inherit some methods like setAttribute, getAttribute,getPage,getRequest etc.

Example: Let’s get understand it with the help of simple example.First we need to create index.jsp file.

#index.jsp: From here we will fill text in textfields and will perform click action of button. Let’s do code for it.

#Output: So the output of above code will look like below image, we have to click on “Click” button after filling data in text fields.

12

#PageContext.jsp: From here we will set our attributes like below code. Here we have set our attributes in PageContext.SESSION_SCOPE and we will get attributes from same SCOPE.

#Output: The output of above code will look like be below image.

13

#pagecontext_second.jsp: Here we will get attribute with the help of PageContext.SESSION_SCOPE, You can get understand it from below code.

#Output: So finally we are done with all work of PageContext implicit object see below image which is output of above code.

14

In this tutorial we have learn about the JSP PageContext Implicit Object and its application with practical example. I hope you will like this tutorial.