In the accepted answer in the following question, a SO regular with 13K+ rep suggests to use a "web bug" (non-cacheable 1x1 img) to be able to track requests in the logs:
http://stackoverflow.com/questions/1784893
How can I do this in Java?
Basically, I've got two issues:
how to make sure the 1x1 image is not cacheable (how to set the header)?
how to make sure the query for these 1x1 image will appear in the logs?
I'm looking for exact piece of code because I know how to write a .jsp/servlet and I know how to serve an 1x1 image :)
My question is really about the exact .jsp/servlet that I should write and how/what needs to be done so that Tomcat logs the request.
For example I plan to use the following mapping:
<servlet-mapping>
<servlet-name>WebBugServlet</servlet-name>
<url-pattern>/webbug*</url-pattern>
</servlet-mapping>
and then use an img tag referencing a "webbug.png" (or .gif), so how do I write the .jsp/servlet?
What/where should I look for in the logs?