Filter, forward to another action


Web tier: servlets, JSP, Web frameworks: Filter, forward to another action

  1. Filter, forward to another action (2 messages)


    How can I forward a user to login page or page informing him that he does not have enough rights to perform some action in a filter? In method doFilter I'm going to call getAttribute("user_profile") in order to obtain user profile and check his rights. Additionally how can I get action mapping for called action in a filter?

    Threaded Messages (2)

  2. See for example Generic postprocessor filter in
  3. in short...[ Go to top ]

    public class MyFilter implements Filter {
        private ServletContext servletContext;
        public void init(FilterConfig config) throws ServletException {
            servletContext = config.getServletContext();

        public void doFilter(ServletRequest req, ServletResponse resp, FilterChain fc) throws ServletException, IOException {
            servletContext.getRequestDispatcher("/somepage.jsp").forward(req, resp);