esta dando um erro que nao consigo descobrir a causa estou no video 1 da aula 6 de servlet ja verifiquei meu codigo como o do video mas nao sei qual e o problema parece que ele nao esta enxergando a classe cookies que eu criei ta dando erro no metodo getUsuario erro: The method buscaUsuarioLogado() is undefined for the type Cookies - The constructor Cookies(Cookie[]) is undefined
segue codigo:
//classe FiltroDeAuditoria!
package br.com.alura.gerenciador.web;
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.annotation.WebFilter;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import org.apache.tomcat.util.http.Cookies;
@WebFilter(urlPatterns = "/*")
public class FiltroDeAuditoria implements Filter{
@Override
public void destroy() {
}
@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
throws IOException, ServletException {
HttpServletRequest req = (HttpServletRequest) request;
String uri = req.getRequestURI();
String usuario = getUsuario(req);
System.out.println("Usuário "+usuario+" acessando a URI: "+ uri);
chain.doFilter(request, response);
}
private String getUsuario(HttpServletRequest req) {
Cookie cookie = new Cookies(req.getCookies()).buscaUsuarioLogado();
if(cookie == null) return "<deslogado>";
return cookie.getValue();
}
@Override
public void init(FilterConfig arg0) throws ServletException {
}
}
//classe Cookies!
package br.com.alura.gerenciador.web;
import javax.servlet.http.Cookie;
public class Cookies {
private final Cookie[] cookies;
public Cookies(Cookie[] cookies) {
this.cookies = cookies;
}
public Cookie buscaUsuarioLogado() {
if(cookies == null) return null;
for (Cookie cookie : cookies) {
if(cookie.getName().equals("usuario.logado")) {
return cookie;
}
}
return null;
}
}