2 Replies Latest reply: May 13, 2013 3:11 AM by ADF Falcon RSS

    Security Filter Servlet

    ADF Falcon

      i am working on JDeveloper

      i want to make a servlet to automatically redirect to login page in case of illegal access

      i searched the internet and find this servlet but it does not work with me ... it opens the login page and whenever i try to login it redirects again to login page ... what shall i change in it to make it work ... here is the code

      import java.io.IOException;

      import javax.servlet.Filter;
      import javax.servlet.FilterChain;
      import javax.servlet.FilterConfig;
      import javax.servlet.ServletException;
      import javax.servlet.ServletRequest;
      import javax.servlet.ServletResponse;
      import javax.servlet.http.HttpServletRequest;
      import javax.servlet.http.HttpServletResponse;
      import javax.servlet.http.HttpSession;

      public class ServletFilter implements Filter {
      private FilterConfig _filterConfig = null;

      public void init(FilterConfig filterConfig) throws ServletException {
      _filterConfig = filterConfig;

      public void destroy() {
      _filterConfig = null;

      public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException,
      ServletException {
      HttpServletRequest MyRequest = (HttpServletRequest)request;
      HttpServletResponse MyResponse = (HttpServletResponse)response;
      HttpSession session = MyRequest.getSession();
      String a = (String)session.getAttribute(“a”);

      if (MyRequest.getRequestURI().toString().endsWith(“/login.jsf”) ||
      MyRequest.getRequestURI().toString().endsWith(“/login”) ||
      MyRequest.getRequestURI().toString().endsWith(“.jpg”) ||
      MyRequest.getRequestURI().toString().endsWith(“.css”) ||
      MyRequest.getRequestURI().toString().endsWith(“.bmp”) ||
      MyRequest.getRequestURI().toString().endsWith(“.gif”) ||
      MyRequest.getRequestURI().toString().endsWith(“.png”) ||
      MyRequest.getRequestURI().toString().endsWith(“.swf”) ||
      MyRequest.getRequestURI().toString().endsWith(“.js”) || a != null) {

      chain.doFilter(MyRequest, MyResponse);
      } else {

      Thanks and Best Regards

      Edited by: user8594936 on 13/05/2013 12:06 ص
        • 1. Re: Security Filter Servlet
          ADF Falcon
          i forget to add the filter code in web.xml


          <servlet-name>Faces Servlet</servlet-name>

          • 2. Re: Security Filter Servlet
            ADF Falcon
            is there any answer to this issue ...