Building banner ad system with Java servlet

Source: Internet
Author: User
Tags integer log

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.