For a business website, the advertising system is essential. A good advertising system is the basis for a website to stabilize revenue. and banner Advertising (banner) is the site advertising accounted for the vast majority of advertising, so the development of a banner advertising system is very important. With the Java Servlet we can easily build our own banner advertising system.
We usually put some pictures on the Web page, set their links to the Advertiser's Web page, and then generate log files to store the number of visitors, the browser's IP and other information, this is the development of the banner advertising system general ideas.
Next, I want to combine an example to explain how to use the Java servlet to build a banner ad system. In the following example, you must use the tag in your HTML file.
There are three ways to use it:
1) banner?config_file or Banner?config=config_file
For example:
In this way you can display a different picture.
2 You can also set your own redirected URL for each picture. Just add a file description to your setup, see the example below, and the servlet needs more descriptive parameters:
So you can support the standard banner ads.
3 You can also have multiple banner ads on the same page. You just need to add "id= an integer value" to the parameter. This value must be a unique integer value on your page! For example, the description for the first banner is:
The second one is:
Some friends will ask, Config_file is what document AH? It is a text file that describes the setup information for the servlet. You can save this file anywhere in your host. Now introduce the parameters, this configuration file has three parameters:
1, Dir=some_directory
Explanation: dir is your banner ad file stored in the directory, you can use the picture format has JPG, gif,png, JPEG and so on. This parameter is required, otherwise the system will complain.
2, Bannerfilename=some_url
Explanation: The banner file uses the following format, for example:
banner.gif=http://www.cnblogs.com/
banner.jpg=http://www.cnblogs.com/
3, Log=some_directory_to_store_log_file
Explanation: The directory where the log files are stored can be any directory on the server.
Appendix 1, log File and format
The Banner system automatically generates two log files per day. respectively, Ddmmyyyyv.txt and Ddmmyyyyc.txt. The first file saves the browsing banner record, and the second file saves the redirected record. All two files are text files, and each row contains one record. The record format is:
IP Address date picture file user agent redirection records (for *c.txt files only), separated by a space between fields.