Java webapp: how to implement a web bug (1x1 pixel)?
Posted
by NoozNooz42
on Stack Overflow
See other posts from Stack Overflow
or by NoozNooz42
Published on 2010-06-10T05:37:48Z
Indexed on
2010/06/10
5:42 UTC
Read the original article
Hit count: 312
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?
© Stack Overflow or respective owner