Rev 1378 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1378 | Rev 1824 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | package pt.estgp.estgweb.web.filters; |
1 | package pt.estgp.estgweb.web.filters; |
2 | 2 | ||
3 | /** |
3 | /** |
4 | * Created by jorgemachado on 24/05/16. |
4 | * Created by jorgemachado on 24/05/16. |
5 | */ |
5 | */ |
- | 6 | ||
- | 7 | import org.apache.log4j.Logger; |
|
- | 8 | import pt.estgp.estgweb.utils.Globals; |
|
- | 9 | ||
6 | import javax.servlet.*; |
10 | import javax.servlet.*; |
7 | import javax.servlet.http.HttpServletResponse; |
11 | import javax.servlet.http.HttpServletRequest; |
8 | import java.io.IOException; |
12 | import java.io.IOException; |
9 | import java.util.Date; |
13 | import java.util.List; |
10 | 14 | ||
11 | public class CacheControlFilter implements 1.5.0/docs/api/java/util/logging/Filter.html">Filter { |
15 | public class UrlDisplayFilter implements 1.5.0/docs/api/java/util/logging/Filter.html">Filter { |
- | 16 | ||
- | 17 | private static 1.5.0/docs/api/java/util/logging/Logger.html">Logger logger = 1.5.0/docs/api/java/util/logging/Logger.html">Logger.getLogger(UrlDisplayFilter.class); |
|
- | 18 | public static final List<String> URL_STAT_IGNORE_EXTENSIONS = Globals.URL_STAT_IGNORE_EXTENSIONS; |
|
12 | 19 | ||
13 | @1.5.0/docs/api/java/lang/Override.html">Override |
20 | @1.5.0/docs/api/java/lang/Override.html">Override |
14 | public void init(FilterConfig filterConfig) throws ServletException { |
21 | public void init(FilterConfig filterConfig) throws ServletException { |
15 | 22 | ||
16 | } |
23 | } |
17 | 24 | ||
18 | public void doFilter(ServletRequest request, ServletResponse response, |
25 | public void doFilter(ServletRequest request, ServletResponse response, |
19 | FilterChain chain) throws 1.5.0/docs/api/java/io/IOException.html">IOException, ServletException { |
26 | FilterChain chain) throws 1.5.0/docs/api/java/io/IOException.html">IOException, ServletException { |
20 | 27 | ||
21 | HttpServletResponse resp = (HttpServletResponse) response; |
28 | HttpServletRequest req = (HttpServletRequest) request; |
22 | resp.setHeader("Expires", "Tue, 03 Jul 2001 06:00:00 GMT"); |
29 | 1.5.0/docs/api/java/lang/String.html">String relativePath = req.getServletPath(); |
- | 30 | if (relativePath == null) |
|
- | 31 | relativePath = ""; |
|
- | 32 | ||
23 | resp.setDateHeader("Last-Modified", new 5+0%2Fdocs%2Fapi+Date">Date().getTime()); |
33 | if (req.getPathInfo() != null && req.getPathInfo().length() > 0) |
- | 34 | { |
|
- | 35 | relativePath += req.getPathInfo(); |
|
- | 36 | } |
|
- | 37 | ||
24 | resp.setHeader("Cache-Control", "no-store, no-cache, must-revalidate, max-age=0, post-check=0, pre-check=0"); |
38 | for (1.5.0/docs/api/java/lang/String.html">String ignore : URL_STAT_IGNORE_EXTENSIONS) |
- | 39 | { |
|
- | 40 | if (relativePath.endsWith(ignore)) |
|
- | 41 | { |
|
25 | resp.setHeader("Pragma", "no-cache"); |
42 | chain.doFilter(request, response); |
- | 43 | return; |
|
- | 44 | } |
|
- | 45 | } |
|
- | 46 | ||
- | 47 | //String sessId = req.getSession() != null ? req.getSession().getId() : " no session "; |
|
26 | 48 | ||
- | 49 | logger.info("url[" + req.getRequestURL().toString() + "] reqSessionId[" + req.getRequestedSessionId() + "] servletPath[" + req.getServletPath() + "] ip[" + req.getRemoteAddr() + "]"); |
|
27 | chain.doFilter(request, response); |
50 | chain.doFilter(request, response); |
28 | } |
51 | } |
29 | 52 | ||
30 | @1.5.0/docs/api/java/lang/Override.html">Override |
53 | @1.5.0/docs/api/java/lang/Override.html">Override |
31 | public void destroy() { |
54 | public void destroy() { |