The applet, when invoked, first checks for the object that specifies the banners, their positions in the document, and their frequencies of appearance. If the object is not in cache, it sends a request to the Web server to fetch the object. The applet then goes through the cached document, and for every image that is specially marked to be an advertisement banner, decides which banner should be put there according to the specifications, and changes the image URL. It then puts the new document in the New_File and returns 1.
The applet implements a simple frequency-based rotation. Other algorithms can be implemented. The applet can record the state needed by the algorithms in the object. It can further record in the log object the banner choices that it has made.