Google News
logo
Java Struts - Interview Questions
How can we get Servlet API Request, Response, HttpSession etc Objects in action classes?
Struts2 action classes don’t provide direct access to Servlet API components such as Request, Response, and Session. However, sometimes we need these access in action classes such as checking HTTP method or setting cookies in response.
 
That’s why Struts2 API provides a bunch of *Aware interfaces that we can implement to access these objects. Struts2 API uses dependency injection to inject Servlet API components in action classes. Some of the important Aware interfaces are SessionAware, ApplicationAware, ServletRequestAware, and ServletResponseAware.
Advertisement