New file |
0,0 → 1,58 |
package pt.estgp.estgweb.web.filters; |
|
/** |
* Created by jorgemachado on 24/05/16. |
*/ |
|
import org.apache.log4j.Logger; |
import pt.estgp.estgweb.utils.Globals; |
|
import javax.servlet.*; |
import javax.servlet.http.HttpServletRequest; |
import java.io.IOException; |
import java.util.List; |
|
public class UrlDisplayFilter implements Filter { |
|
private static Logger logger = Logger.getLogger(UrlDisplayFilter.class); |
public static final List<String> URL_STAT_IGNORE_EXTENSIONS = Globals.URL_STAT_IGNORE_EXTENSIONS; |
|
@Override |
public void init(FilterConfig filterConfig) throws ServletException { |
|
} |
|
public void doFilter(ServletRequest request, ServletResponse response, |
FilterChain chain) throws IOException, ServletException { |
|
HttpServletRequest req = (HttpServletRequest) request; |
String relativePath = req.getServletPath(); |
if (relativePath == null) |
relativePath = ""; |
|
if (req.getPathInfo() != null && req.getPathInfo().length() > 0) |
{ |
relativePath += req.getPathInfo(); |
} |
|
for (String ignore : URL_STAT_IGNORE_EXTENSIONS) |
{ |
if (relativePath.endsWith(ignore)) |
{ |
chain.doFilter(request, response); |
return; |
} |
} |
|
//String sessId = req.getSession() != null ? req.getSession().getId() : " no session "; |
|
logger.info("url[" + req.getRequestURL().toString() + "] reqSessionId[" + req.getRequestedSessionId() + "] servletPath[" + req.getServletPath() + "] ip[" + req.getRemoteAddr() + "]"); |
chain.doFilter(request, response); |
} |
|
@Override |
public void destroy() { |
|
} |
|
} |