I am using a servlet filter where I am trying to get the action associated with the current request.
Relevant sections of my filter:
private ServletContext context;
public void init(FilterConfig config) throws ServletException {
this.context = config.getServletContext();
}
protected void doFilter(HttpServletRequest request, HttpServletResponse response,
FilterChain chain) throws IOException, ServletException {
ServletActionContext actionContext = new ServletActionContext(context, request, response);
Action action = actionContext.getAction();
// action == null
}
My problem is that action
ends up being null. Both of the context variables get populated with a value, but for some reason it cant find the action. Any ideas? Thanks!
ServletActionContext are initialised and all required variable are filled properly when control pass through ActionServlet.
Filter are executed before ActionServlet and and Creating object in filter method doesnt set Action
That is the main reason because of that some getter method of ServletActionContext returns null values because it doesn't gone through ActionServlet and hence all properties are not initialised.