0
How do I identify by which URL
a filter is being accessed?
My situation is as follows:
I have the class below:
@WebFilter(filterName = "FiltroLogado", urlPatterns = {"/alterar.jsp",
"/deletar.jsp", "/cadastrado.jsp", "/logado.jsp"})
public class FiltroLogado implements Filter{
@Override
public void init(FilterConfig filterConfig) throws ServletException {
}
@Override
public void doFilter(ServletRequest servletRequest, ServletResponse
servletResponse, FilterChain filterChain) throws IOException,
ServletException {
HttpSession session = ((HttpServletRequest)
servletRequest).getSession();
if (session.getAttribute("usuario") == null){
((HttpServletResponse) servletResponse).sendRedirect("index.jsp");
}else
if(){
((HttpServletResponse) servletResponse).sendRedirect("alterar.jsp");
}
}
I want to know by which URL
the filter is being accessed to forward to the specific location of the link, for example by accessing the filter through the URL "/alterar.jsp"
, I want him to go to "/alterado.jsp"
.
Yes. My doubt was about the method, but I already found it. Thank you.
– Welber Duarte