top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

How can we get Servlet API Request, Response, HttpSession etc Objects in action classes?

+1 vote
421 views
How can we get Servlet API Request, Response, HttpSession etc Objects in action classes?
posted Nov 27, 2017 by Frank Lee

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

Struts2 action classes doesn’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.

Thats 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.

answer Nov 28, 2017 by Manikandan J
...