Problema com Filtro de Login

Bom dia pessoal estou fazendo apenas um CRUD em JSP pra fixar o conhecimento mas empaquei em um Filtro que fiz pra validar a sessão do usuário. Se alguém puder ajudar … agradeço.

Bem tenho esse Filtro.

[code]
public void doFilter(ServletRequest request, ServletResponse response,
FilterChain chain)
throws IOException, ServletException {

    System.out.println("LoginFilter");
    HttpServletRequest req = (HttpServletRequest) request;
    HttpServletResponse res = (HttpServletResponse) response;
    Object logged = req.getSession().getAttribute("islogged");
    String url = req.getSession().toString();
    System.out.println("URL = " + url);

    if (logged == null && !url.contains("logininvalid.jsp")) 
        res.sendRedirect("login.jsp");

        chain.doFilter(request, response);

    }[/code]

Meu web.xml

<filter> <filter-name>loginFilter</filter-name> <filter-class>webapp.servlet.filters.LoginFilter</filter-class> </filter> <filter-mapping> <filter-name>loginFilter</filter-name> <url-pattern>/WebApp/*</url-pattern> </filter-mapping> <servlet>

O login está funcionando, porém quando o sistema inicia vai pra página principal, o filtro não direciona para a página de login.

Acabei de testar assim novamente e não foi

if (1+1 == 2) res.sendRedirect("login.jsp");

Minha pilha de erro.

GRAVE: Exception starting filter LoginFilter java.lang.ExceptionInInitializerError at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27) at java.lang.reflect.Constructor.newInstance(Constructor.java:513) at java.lang.Class.newInstance0(Class.java:355) at java.lang.Class.newInstance(Class.java:308) at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:255) at org.apache.catalina.core.ApplicationFilterConfig.setFilterDef(ApplicationFilterConfig.java:397) at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:108) at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:3709) at org.apache.catalina.core.StandardContext.start(StandardContext.java:4363) at org.apache.catalina.core.StandardContext.reload(StandardContext.java:3099) at org.apache.catalina.manager.ManagerServlet.reload(ManagerServlet.java:916) at org.apache.catalina.manager.ManagerServlet.doGet(ManagerServlet.java:360) at javax.servlet.http.HttpServlet.service(HttpServlet.java:617) at javax.servlet.http.HttpServlet.service(HttpServlet.java:717) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:196) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:525) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583) at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447) at java.lang.Thread.run(Thread.java:662) Caused by: java.lang.RuntimeException: Uncompilable source code - webapp.servlet.filters.LoginFilter is not abstract and does not override abstract method doFilter(javax.servlet.ServletRequest,javax.servlet.ServletResponse,javax.servlet.FilterChain) in javax.servlet.Filter at webapp.servlet.filters.LoginFilter.<clinit>(LoginFilter.java:25) ... 32 more

Chapolim,

Vc precisa setar o atributo “islogged” na sessão quando o usuario digitar a senha correta, caso contrario a aplicação nunca irá encontrar esse atributo.

Abç