Updates
  • Starting New Weekday Batch for Full Stack Java Development on 27 September 2025 @ 03:00 PM to 06:00 PM
  • Starting New Weekday Batch for MERN Stack Development on 29 September 2025 @ 04:00 PM to 06:00 PM

Servlet Scopes

• There are 3 scopes available in Servlet.

o Request scope
o Session scope
o Context or Application scope

• You can store and manipulate data with the above-scoped objects as attributes with the following methods:

o Void setAttribute(String, Objetc)
o Void removeAttribute(String)
o Object getAttribute(String)
o Enumeration getAttributeNames()

Request Scope

• When the data is stored in the HttpServletRequest object, the scope will be request scope.
• The data from the request scope can be accessed by that single user in that request only before sending the request to the client.

Session Scope

• When the data is stored in the HttpSession object, the scope will be session scope.
• The data from session scope can be accessed by a single user across multiple requests (within the same session).

Context or Application Scope

• When the data is stored in the servletContext object, the scope will be context scope.
• The data from the context or application scope can be accessed by multiple users across multiple requests.