Servlet A receives a request that it forwards to servlet B within another webapplication in the same web container. Servlet A needs to share data with servlet B and that data mustnot be visible to other servlets in A's web application. In which object can the data that A shares with Bbe stored?
-
HttpSession
-
ServletConfig
-
ServletContext
-
HttpServletRequest
-
HttpServletResponse
D
Correct answer
Explanation
When forwarding requests between servlets in different web applications, the session and servlet context are not shared. HttpServletRequest attributes are preserved during forward operations and are accessible only to the target servlet, making them the ideal mechanism for data sharing in this scenario. HttpSession and ServletContext are shared within the same web application, not across applications.