---
description: JSP implicit objects are created during the translation phase of JSP to the servlet. There are nine types of implicit objects such as Out, Request, Config, etc
title: JSP Implicit Objects
image: https://www.guru99.com/images/jsp-implicit-objects-1.png
---

 

[Skip to content](#main) 

**⚡ Smart Summary**

JSP Implicit Objects are predefined variables that the servlet container creates automatically during page translation, allowing developers to access output streams, requests, responses, sessions, and application data directly inside a page without manual declaration or extra configuration.

* 🖨️ **Out Object:** Writes data to the buffer and sends output to the client through the JspWriter stream.
* 📥 **Request Object:** An instance of HttpServletRequest that retrieves parameters, headers, and server details using getParameter().
* 📤 **Response Object:** Implements HttpServletResponse to set the content type, add cookies, and redirect the client.
* ⚙️ **Config and Application:** Config reads initialization parameters from web.xml; Application shares context data across the entire deployment.
* 🗂️ **Session and PageContext:** Session persists user attributes across pages; PageContext manages attributes across page, request, session, and application scopes.
* ⚠️ **Exception Object:** A Throwable available only on error pages that reports runtime errors such as ArrayIndexOutOfBounds.

[ Read More ](javascript:void%280%29;) 

![]()

## What is JSP Implicit object?

* JSP implicit objects are created during the translation phase of JSP to the servlet.
* These objects can be directly used in scriplets that goes in the service method.
* They are created by the container automatically, and they can be accessed using objects.

## How many Implicit Objects are available in JSP?

There are 9 types of implicit objects available in the container:

1. Out
2. Request
3. Response
4. Config
5. Application
6. Session
7. PageContext
8. Page
9. Exception

Lets study One By One

## 1) Out

* Out is one of the implicit objects to write the data to the buffer and send output to the client in response
* Out object allows us to access the servlet’s output stream
* Out is object of javax.servlet.jsp.jspWriter class
* While working with [servlet](https://www.guru99.com/difference-between-servlets-vs-jsp.html), we need printwriter object

**Example:**

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Implicit Guru JSP1</title>
</head>
<body>
<% int num1=10;int num2=20;
out.println("num1 is " +num1);
out.println("num2 is "+num2);
%>
</body>
</html>

**Explanation of the code:**

**Code Line 11-12**– out is used to print into output stream

When we execute the above code, we get the following output:

[](https://www.guru99.com/images/jsp/022716%5F0953%5FJSPActionsJ8.png)

**Output:**

* In the output, we get the values of num1 and num2

## 2) Request

* The request object is an instance of java.servlet.http.HttpServletRequest and it is one of the argument of service method
* It will be created by container for every request.
* It will be used to request the information like parameter, header information , server name, etc.
* It uses getParameter() to access the request parameter.

**Example:**

Implicit\_jsp2.jsp(form from which request is sent to guru.jsp)

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Implicit Guru form JSP2</title>
</head>
<body>
<form action="guru.jsp">
<input type="text" name="username">
<input type="submit" value="submit">
</form>
</body>
</html>

Guru.jsp (where the action is taken)

[](https://www.guru99.com/images/jsp/022716%5F0953%5FJSPActionsJ10.png)

**Explanation of code:**

**Code Line 10-13 :** In implicit\_jsp2.jsp(form) request is sent, hence the variable username is processed and sent to guru.jsp which is action of JSP.

Guru.jsp

**Code Line10-11:** It is action jsp where the request is processed, and username is taken from form jsp.

When you execute the above code, you get the following output

**Output:**

[](https://www.guru99.com/images/jsp/022716%5F0953%5FJSPActionsJ11.png)

When you write test and click on the submit button, then you get the following output “Welcome Test.”

[](https://www.guru99.com/images/jsp/022716%5F0953%5FJSPActionsJ12.png)

### RELATED ARTICLES

* [JSP Life Cycle: Phases & Diagram Explained ](https://www.guru99.com/jsp-life-cycle.html "JSP Life Cycle: Phases & Diagram Explained")
* [JSP Program Examples: Registration & Login Form ](https://www.guru99.com/jsp-example.html "JSP Program Examples: Registration & Login Form")
* [JSP Action Tags ](https://www.guru99.com/jsp-action-tags.html "JSP Action Tags")
* [Cookies in JSP With Example ](https://www.guru99.com/jsp-cookies-handling.html "Cookies in JSP With Example")

## 3) Response

* “Response” is an instance of class which implements HttpServletResponse interface
* Container generates this object and passes to \_jspservice() method as parameter
* “Response object” will be created by the container for each request.
* It represents the response that can be given to the client
* The response implicit object is used to content type, add cookie and redirect to response page

**Example:**

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Implicit Guru JSP4</title>
</head>
<body>
<%response.setContentType("text/html"); %>
</body>
</html>

**Explanation of the code:**

**Code Line 11:** In the response object we can set the content type

Here we are setting only the content type in the response object. Hence, there is no output for this.

## 4) Config

* “Config” is of the type java.servlet.servletConfig
* It is created by the container for each jsp page
* It is used to get the initialization parameter in web.xml

**Example:**

Web.xml (specifies the name and mapping of the servlet)

[](https://www.guru99.com/images/jsp/022716%5F0953%5FJSPActionsJ14.png)

Implicit\_jsp5.jsp (getting the value of servlet name)

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Implicit Guru JSP5</title>
</head>
<body>
<% String servletName = config.getServletName();
out.println("Servlet Name is " +servletName);%>
</body>
</html>

**Explanation of the code:**

In web.xml

**Code Line 14-17:** In web.xml we have mapping of servlets to the classes.

Implicit\_jsp5.jsp

**Code Line 10-11:** To get the name of the servlet in JSP, we can use config.getServletName, which will help us to get the name of the servlet.

When you execute the above code you get the following output:

[](https://www.guru99.com/images/jsp/022716%5F0953%5FJSPActionsJ16.png)

**Output:**

* Servlet name is “GuruServlet” as the name is present in web.xml

## 5) Application

* Application object (code line 10) is an instance of javax.servlet.ServletContext and it is used to get the context information and attributes in JSP.
* Application object is created by container one per application, when the application gets deployed.
* Servletcontext object contains a set of methods which are used to interact with the servlet container.We can find information about the servlet container

**Example:**

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Guru Implicit JSP6</title>
</head>
<body>
<% application.getContextPath(); %>
</body>
</html>

**Explanation of the code:**

* In the above code, application attribute helps to get the context path of the JSP page.

## 6) Session

* The session is holding “httpsession” object(code line 10).
* Session object is used to get, set and remove attributes to session scope and also used to get session information

**Example:**

Implicit\_jsp7(attribute is set)

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Implicit JSP</title>
</head>
<body>
<% session.setAttribute("user","GuruJSP"); %>
<a href="implicit_jsp8.jsp">Click here to get user name</a>
</body>
</html>

Implicit\_jsp8.jsp (getAttribute)

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>implicit Guru JSP8</title>
</head>
<body>
<% String name = (String)session.getAttribute("user");
out.println("User Name is " +name);
%>
</body>
</html>

**Explanation of the code:**

Implicit\_jsp7.jsp

**Code Line 11:** we are setting the attribute user in the session variable, and that value can be fetched from the session in whichever jsp is called from that (\_jsp8.jsp).

**Code Line 12:** We are calling another jsp on href in which we will get the value for attribute user which is set.

Implicit\_jsp8.jsp

**Code Line 11:** We are getting the value of user attribute from session object and displaying that value

When you execute the above code, you get the following output:

[](https://www.guru99.com/images/jsp/022716%5F0953%5FJSPActionsJ20.png)

When you click on the link for the username. You will get the following output.

[](https://www.guru99.com/images/jsp/022716%5F0953%5FJSPActionsJ21.png)

**Output:**

* When we click on link given in implicit\_jsp7.jsp then we are redirected to second jsp page, i.e (\_jsp8.jsp) page and we get the value from session object of the user attribute (\_jsp7.jsp).

## 7) PageContext

* This object is of the type of pagecontext.
* It is used to get, set and remove the attributes from a particular scope

Scopes are of 4 types:

* Page
* Request
* Session
* Application

**Example:**

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Implicit Guru JSP9</title>
</head>
<body>
<% pageContext.setAttribute("student","gurustudent",pageContext.PAGE_SCOPE);
String name = (String)pageContext.getAttribute("student");
out.println("student name is " +name);
%>
</body>
</html>

**Explanation of the code:**

**Code Line 11:** we are setting the attribute using pageContext object, and it has three parameters:

* Key
* Value
* Scope

In the above code, the key is student and value is “gurustudent” while the scope is the page scope. Here the scope is “page” and it can get using page scope only.

**Code Line 12:** We are getting the value of the attribute using pageContext

When you execute the above code, you get the following output:

[](https://www.guru99.com/images/jsp/022716%5F0953%5FJSPActionsJ23.png)

**Output:**

* The output will print “student name is gurustudent”.

## 8) Page

* Page implicit variable holds the currently executed servlet object for the corresponding jsp.
* Acts as this object for current jsp page.

**Example:**

In this example, we are using page object to get the page name using toString method

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Implicit Guru JSP10</title>
</head>
<body>
<% String pageName = page.toString();
out.println("Page Name is " +pageName);%>
</body>
</html>

**Explanation of the code:**

**Code Line 10-11:** In this example, we are trying to use the method toString() of the page object and trying to get the string name of theJSP Page.

When you execute the code you get the following output:

[](https://www.guru99.com/images/jsp/022716%5F0953%5FJSPActionsJ25.png)

**Output:**

* Output is string name of above jsp page

## 9) Exception

* Exception is the implicit object of the throwable class.
* It is used for [exception handling in JSP](https://www.guru99.com/jsp-exception-handling.html).
* The exception object can be only used in error pages.**Example:**

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1" isErrorPage="true"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Implicit Guru JSP 11</title>
</head>
<body>
<%int[] num1={1,2,3,4};
out.println(num1[5]);%>
<%= exception %>
</body>
</html>

**Explanation of the code:**

**Code Line 10-12** – It has an array of numbers, i.e., num1 with four elements. In the output, we are trying to print the fifth element of the array from num1, which is not declared in the array list. So it is used to get exception object of the jsp.

**Output:**

[](https://www.guru99.com/images/jsp/022716%5F0953%5FJSPActionsJ27.png)

We are getting ArrayIndexOfBoundsException in the array where we are getting a num1 array of the fifth element.

## FAQs

❓ Do JSP implicit objects need to be declared before use?

No. The container creates all nine implicit objects automatically during the translation phase. Developers can use them directly inside scriptlets and the service method without importing packages or declaring any variables.

🧩 Are JSP implicit objects available inside JSP declarations?

No. Implicit objects are available only inside scriptlets and expressions that map to the service method. They cannot be used inside JSP declaration tags, which generate class-level members outside that method.

🗂️ Which implicit object works across multiple scopes?

PageContext works across all four scopes—page, request, session, and application. It provides setAttribute, getAttribute, and removeAttribute methods, making it the most flexible implicit object for managing data across different scope levels.

🤖 How can AI help developers learn JSP implicit objects?

AI can explain each implicit object with examples, convert scriptlet code into cleaner alternatives, and answer scope questions instantly. This helps beginners understand when to use the request, session, or application objects correctly.

🤖 Can AI generate JSP code that uses implicit objects?

Yes. AI tools can generate working JSP snippets using out, request, session, and other implicit objects, then explain each line. Developers should still review the output for correct scope handling and security.

#### Summarize this post with:

ChatGPT Perplexity Grok Google AI 

**Stay Updated on AI** **Get Weekly AI Skills, Trends, Actionable Advice.** 

##### Sign up for the newsletter

Subscribe for Free 

You have successfully subscribed.  
Please check your inbox. 

![AI-Newsletter]() Chosen by over **350,000+** professionals 

[Scroll to top ](#wrapper)Scroll to top 

× 

Toggle Menu Close 

Search for: 

Search

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://www.guru99.com/#organization","name":"Guru99","sameAs":["https://www.facebook.com/Guru99Official","https://twitter.com/guru99com"],"logo":{"@type":"ImageObject","@id":"https://www.guru99.com/#logo","url":"https://www.guru99.com/images/guru99-logo-v1-150x59.png","contentUrl":"https://www.guru99.com/images/guru99-logo-v1-150x59.png","caption":"Guru99","inLanguage":"en-US"}},{"@type":"WebSite","@id":"https://www.guru99.com/#website","url":"https://www.guru99.com","name":"Guru99","publisher":{"@id":"https://www.guru99.com/#organization"},"inLanguage":"en-US"},{"@type":"ImageObject","@id":"https://www.guru99.com/images/jsp-implicit-objects-1.png","url":"https://www.guru99.com/images/jsp-implicit-objects-1.png","width":"700","height":"250","caption":"JSP Implicit Objects","inLanguage":"en-US"},{"@type":"BreadcrumbList","@id":"https://www.guru99.com/jsp-implicit-objects.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":"1","item":{"@id":"https://www.guru99.com","name":"Home"}},{"@type":"ListItem","position":"2","item":{"@id":"https://www.guru99.com/jsp","name":"JSP"}},{"@type":"ListItem","position":"3","item":{"@id":"https://www.guru99.com/jsp-implicit-objects.html","name":"JSP Implicit Objects"}}]},{"@type":"WebPage","@id":"https://www.guru99.com/jsp-implicit-objects.html#webpage","url":"https://www.guru99.com/jsp-implicit-objects.html","name":"JSP Implicit Objects","dateModified":"2026-07-01T17:41:35+05:30","isPartOf":{"@id":"https://www.guru99.com/#website"},"primaryImageOfPage":{"@id":"https://www.guru99.com/images/jsp-implicit-objects-1.png"},"inLanguage":"en-US","breadcrumb":{"@id":"https://www.guru99.com/jsp-implicit-objects.html#breadcrumb"}},{"@type":"Person","@id":"https://www.guru99.com/author/james","name":"James Hartman","description":"I am James Hartman, a seasoned professional in Oracle Certified Java Professional tutorials, specializing in crafting comprehensive guides to help you excel in your Java certification journey.","url":"https://www.guru99.com/author/james","image":{"@type":"ImageObject","@id":"https://www.guru99.com/images/james-hartman-author-v2-120x120.png","url":"https://www.guru99.com/images/james-hartman-author-v2-120x120.png","caption":"James Hartman","inLanguage":"en-US"},"worksFor":{"@id":"https://www.guru99.com/#organization"}},{"articleSection":"JSP","headline":"JSP Implicit Objects","description":"JSP implicit objects are created during the translation phase of JSP to the servlet. There are nine types of implicit objects such as Out, Request, Config, etc","keywords":"jsp","speakable":{"@type":"SpeakableSpecification","cssSelector":[".entry-title",".summary"]},"@type":"Article","author":{"@id":"https://www.guru99.com/author/james","name":"James Hartman"},"dateModified":"2026-07-01T17:41:35+05:30","image":{"@id":"https://www.guru99.com/images/jsp-implicit-objects-1.png"},"copyrightYear":"2026","name":"JSP Implicit Objects","subjectOf":[{"@type":"FAQPage","mainEntity":[{"@type":"Question","name":"Do JSP implicit objects need to be declared before use?","acceptedAnswer":{"@type":"Answer","text":"No. The container creates all nine implicit objects automatically during the translation phase. Developers can use them directly inside scriptlets and the service method without importing packages or declaring any variables."}},{"@type":"Question","name":"Are JSP implicit objects available inside JSP declarations?","acceptedAnswer":{"@type":"Answer","text":"No. Implicit objects are available only inside scriptlets and expressions that map to the service method. They cannot be used inside JSP declaration tags, which generate class-level members outside that method."}},{"@type":"Question","name":"Which implicit object works across multiple scopes?","acceptedAnswer":{"@type":"Answer","text":"PageContext works across all four scopes\u2014page, request, session, and application. It provides setAttribute, getAttribute, and removeAttribute methods, making it the most flexible implicit object for managing data across different scope levels."}},{"@type":"Question","name":"How can AI help developers learn JSP implicit objects?","acceptedAnswer":{"@type":"Answer","text":"AI can explain each implicit object with examples, convert scriptlet code into cleaner alternatives, and answer scope questions instantly. This helps beginners understand when to use the request, session, or application objects correctly."}},{"@type":"Question","name":"Can AI generate JSP code that uses implicit objects?","acceptedAnswer":{"@type":"Answer","text":"Yes. AI tools can generate working JSP snippets using out, request, session, and other implicit objects, then explain each line. Developers should still review the output for correct scope handling and security."}}]}],"@id":"https://www.guru99.com/jsp-implicit-objects.html#schema-1128312","isPartOf":{"@id":"https://www.guru99.com/jsp-implicit-objects.html#webpage"},"publisher":{"@id":"https://www.guru99.com/#organization"},"inLanguage":"en-US","mainEntityOfPage":{"@id":"https://www.guru99.com/jsp-implicit-objects.html#webpage"}}]}
```
