How do I identify by which URL
is being accessed a filter?
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 why URL
the filter is being accessed to forward to the specific place of the link, for example, when accessing the filter by URL "/alterar.jsp"
, I want it to go to "/alterado.jsp"
.