Chapter 6. Who's There? Logging Access to Your Website with WebLogger
Want to know who's been accessing your website? Want to track them by IP address, browser type, even username? WebLogger lets you log information about the people who come to a website, without their knowledge. Unless you tell them, they have no way of knowing that they've been tracked as you log their time of access, where on your site they went, what their username is (if they logged in to your website, as you're going to see how to do), what their IP address is (and if they have cable access, they have a fixed IP address), how long they worked with the web page they accessed, and what type of browser they have.
Want to get a handle on who comes to your site and how long they stay? Then WebLogger's for you.
Using WebLogger, you can track users as they move around your site. In fact, you can even block access if you want. What does the user see? Nothing at all, as shown in Figure 6.1, where the user is accessing a page called target.jspexcept for the text WebLogger has added to the bottom of the page. Unless that added text informed the user that he was being tracked (and, of course, you can remove that text from WebLogger), he would have no way of knowing it.
Figure 6.1. WebLogger at work.
Here's the information that's logged for each user:
Here's what the report will look like. You can have this logged in the web server's logs or in a separate log file of your own creationWebLogger lets you do either:
User access at Mon Mar 07 15:47:53 EST 2006 Authentication type: BASIC User name: steve User IP: 127.0.0.1 Accessing: /logger/target.jsp Host: 127.0.0.1 Browser: Internet Explorer Milliseconds used: 109
To make what it does possible, WebLogger uses a filter. You can get your hands on the data sent to JSPs and servlets, and on the data they return, using filters. All you have to do is to write your filter, compile it, and install it so that the web server only grants access to the web resource you're filtering through that filter. And that gives you complete control.