Java servlet allows you to display rotated banners. You must set this servlet as an <img> tag attribute in your html-file.
How to use it:
a) copy bannerPackage.jar into your WEB-INF/lib directory.
b) define BannerServlet in your web.xml file:
c) define a mapping:
In order to use servlet you have to prepare a text configuration file. This file describes
your pictures, how to show them etc. Configuration file will be passed to servlet as a parameter
or as an initial parameter. So there are two basic forms for usage:
or you may describe config_file as an initial parameter for servlet (parameter name is config)
in your web.xml file:
and use servlet in this form:
So in your HTML file you will have some like this:
Such way you can just display different images.
b) you can set own redirection URL for the each picture. In this
case your configuration must have files description (see below) and servlet
requires more parameters:
Such way you can support standard advertising banners
c) you can have more than one advertising banner
on the page. In this case just add to the each entry the parameter id=some_unique_integer_value.
These values must be unique within your page. So, for example the first
banner may be described as:
and the second is:
If you are using an intial parameter, than just remove config= part from URL. E.g.:
<a href="http://your_host/servlet/BannerServlet?mode=2&id=2">
<img src="http://your_host/servlet/BannerServlet?mode=1&id=2"
width=125 height=125></a>
Configuration file is a text file describes servlet's settings. You can save this file anywhere on your server. Configuration file has got free format, but description of any parameter must starts with the appropriate reserved word on the new line. Empty lines and any line starts with # or // are ignored.
Current version supports the following list of parameters:
# dir. Base directory for your banners. Servlet will output on the round-robin
schema
# files from this directory with extensions GIF, JPG, JPEG, PNG.
# This parameter is mandatory.
dir=some_directory_on_your_server
# files description in the form of:
# filename=appropriate_url. E.g.:
banner1.gif=http://www.acme.com
banner2.jpg=http://www.acme1.com
# how to rotate banners.
# 0 - per session (each user will have own loop)
# 1 - per application (one loop for all visitors)
# Default value is 0.
rotate=0
# Logging
# directory for log files
log=some_existing_directory_on_your_server
or
# file name
log=path_to_some_file_on_your_server
Log files
You can describe an existing directory for log files on your server. In this case servlet will create two log files per day. File name is ddmmyyyyv.txt and ddmmyyyyc.txt Where dd is a day, mm is a month and yyyy is a year. E.g. for Dec 18 2000 files are 18122000v.txt and 18122000c.txt
Alternatively you may set some generic file name. E.g. in your config set:
log=c:\data\adlog
where c:\data\adlog is not a directory. In this case servlet will save
all data (for all days) in two files: c:\data\adlogv.txt and c:\data\adlogc.txt
First file (ends with v) keeps records about views and the second (ends with c) keeps
records about redirections. Both files are text files with one record per line. Record
format is (fields are separated with spaces):
How to rotate images without page reloading
You can use JavaScript for this. For example, this code rotates banners after 3 seconds:
Notes:
1. Banner's configuration file can be saved anywhere on your server. E.g. if you are using BannerServlet?config line we assume this file is saved under the root (docBase) directory of your servletrunner. But you can of course always use the full path for setting config file location: BannerServlet?/home/users/my_file (or BannerServlet?c:\users\my_file)
2. Base directory is any existing directory (with banner files) on your server.
3. Evaluation version supports up to 3 banners per configuration file
for downloading:
servlet: bannerPackage.jar
See also JSOS - the largest collection of servlets and filters.