Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I always think that you should be able to make exceptions to url-patterns in a web.xml e.g. if you could do something like this:</p> <pre><code>&lt;filter-mapping&gt; &lt;filter-name&gt;MyFilter&lt;/filter-name&gt; &lt;url-pattern&gt; &lt;match&gt;/resources/*&lt;/match&gt; &lt;except&gt;/resouces/images/blah.jpg&lt;/except&gt; &lt;/url-pattern&gt; </code></pre> <p>but you can't so that's no help to you!</p> <p>You obviously have access to the URL in the Filter through the request object so you could do something like this:</p> <pre><code>public void doFilter(ServletRequest sRequest, ServletResponse sResponse, FilterChain chain) throws IOException, ServletException { HttpServletRequest request = (HttpServletRequest)sRequest; if(!request.getRequestURI.equals("/resources/images/blah.jpg")) { doLogging(); } chain.doFilter(); } </code></pre> <p>(hard-coded here but you'd probably read it from a property file) although this may not be of use to you as you mentioned servlets in your query as opposed to URL patterns.</p> <p>EDIT: another thought. If you don't mind doing your logging after the servlet has completed you could do something like this:</p> <pre><code>public void doFilter(ServletRequest sRequest, ServletResponse sResponse, FilterChain chain) throws IOException, ServletException { sRequest.setAttribute("DO_LOGGING", new Boolean(true)); chain.doFilter(); Boolean doLogging = (Boolean)sRequest.getAttribute("DO_LOGGING"); if(doLogging) { doLogging(); } } </code></pre> <p>and your servlet that you want to exclude from logging can just set that attribute to false.</p> <pre><code>public void doGet(HttpServletRequest req, HttpServletResponse res) throws IOException { req.setAttribute("DO_LOGGING", new Boolean(false)); // other stuff } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload