|Home > FAQs > How can we access the HttpServletResponse|
You can obtain the request by asking the ActionContext or implementing ServletResponseAware. Implementing ServletResponseAware is preferred.
The response is available on the ActionContext instance, which is made available via ThreadLocal.
servlet-configInterceptor is included in the Action's stack.
setServletResponsemethod. You may wish to include a companion
getServletResponseto obtain a reference to the response object.
servlet-config Interceptor sees that an Action implements ServletResponseAware, it passes a reference to the request the Action's
It is more difficult to test Actions with runtime dependencies on HttpServletReponse. Only implement ServletResponseAware as a last resort. A better approach to solving a use case involving the response may be with a custom Result Type.