Multiple choice technology web technology

Name the class that includes the getSession method that is used to get the HttpSession object.

  1. SessionContext

  2. SessionConfig

  3. HttpServletRequest

  4. HttpServletResponse

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

The HttpServletRequest interface provides the getSession() method to retrieve the HttpSession object. This is part of the Java Servlet API for session management in web applications.

AI explanation

HttpServletRequest is the interface that declares getSession(), which returns the HttpSession object associated with the current request (creating a new one if none exists, when called with no arguments or with true). SessionContext and SessionConfig aren't standard Servlet API types with this responsibility, and HttpServletResponse is used to write output/set headers/redirects — session retrieval is a request-side concern, not a response-side one.