Book Store Referral Applet Book Store Referral Applet
home Student Projects no local find frame, full screen Google search web for topic jump to footer translate with Babelfish by Roedy Green ©1996-2008 Canadian Mind Products
This essay is about a suggested student project in Java programming. This essay gives a rough overview of how it might work. It does not describe an actual complete program. I have no source, object, specifications, file layouts or anything else useful to implementing this project. Everything I have to say to help you with this project is written below. I am not prepared to help you implement it; I have too many other projects of my own.

I do contract work for a living, which could include writing a program such as this. However, I don’t do people’s homework for them. That just robs them of an education.

You have my full permission to implement this project any way you please.

This is one of the amanuensis projects. The intent of this Applet is to allow you to automatically specify and keep up to date several sources for a book you mention in a web page. If you buy a book I recommend via a link to Amazon on my website, I will get a 15% commission. If you buy something else I will get 5%.

However, Amazon is not necessarily the best place for you to buy the book. If you look in the Java & Internet Glossary under Book Stores you will find a list of quite a few on-line book stores. One may have the book more cheaply. One may be located closer to you. You may have a special discount arrangement with one. Another may be able to deliver it more quickly. You may have had a particularly bad or good experience with some store. Some stores may not accept the credit cards you use.

On my side, I may make even more lucrative arrangements with other bookstores, that carry a smaller selection of books. I don’t have the time to keep track of which bookstores carry which books and which stores have the best prices on each book. I don’t know from day to day which is the best place to buy each book. Further, there is no best place. It depends on too many factors. It would be better if clicking gave you a choice of vendors, like this:

book_cover recommend book⇒Handbook to Higher Consciousness
 paperbackhardcover
ISBN10:0-9600688-8-00-9600688-9-9
ISBN13:978-0-9600688-8-3978-0-9600688-9-0
publisher:Love Line
published:1984-08
by:Ken Keyes Jr.
Ken’s classic. This is by far his best selling book.
Canadian flag amazon.ca. amazon.com. American flag
Canadian flag chapters.indigo.ca . powells.com American flag
French flag amazon.fr. barnesandnoble.com American flag
German flag amazon.de. amazon.co.uk. UK flag

I hope it is coming clear ideally what this Applet does. You click on the book, and it shows you just the bookstores that carry the book, their price (including shipping, duty and taxes), delivery time, sorted in descending order either by price or estimated delivery time. It also tells you how fresh/reliable the information is (perhaps using icons) for each bookstore. It may further automatically filter out stores that don’t handle one of your available cards, or use icons to show which ones are accepted.

I have already done a crude version of this that just builds links to three bookstores without checking prices or availability.

Instead of embedding a reference to Amazon in my HTML, I would embed a reference to the comparison shopper Applet/servlet, along with the book’s ISBN as a parameter.

The scheme would let you go visit any of the book stores and then do your shopping and browsing there directly. The Applet’s job is simply to direct the people to the most promising on-line bookstores for each book.

If you want to get even more clever, you can hook into the search engines of the various stores to determine the ISBN when the user does not know that, then use the ISBN to go comparison shopping.

Your little engine can work given any ISBN. It need not be one you have on file. The comparison shopper on the server goes out looking while the customer waits. It might even provide estimated prices and availability when it can’t get through right away to all the bookstores.

After you have all this working, you might do a thin client version as well, that does not require an Applet. It works by generating pure HTML at the server.

You can write a very simple version of this program that just directs the user to a generated page that takes you to several bookstores. A CGI Java Servlet generates HTML code. This is valuable even without the comparison shopper feature because:

  1. It can generate revenues even when the customer does not buy from your "official" associate. You get money no matter what store he buys from, so long as you have a refer deal set up either directly or indirectly with the store.
  2. You get the full specific ISBN commission, even if you don’t list the book in your webstore. Stores give higher referral fees when you mention the ISBN number than if the user finds the book by browsing.

How to Make Money

You can make money with this if you make commission arrangements with most or all the bookstores you refer to. Further you can rent out your Applet and possibly database server service as well to owners of other websites containing referrals to books. They would then get the referral commissions. They may simply use your Applet free, and you get the commissions or split them 50/50. The benefit to them is pleasing people browsing their website.

Most commonly you would offer to share the proceeds of the referral fees with anyone who puts the Applet up on their site. That way people who use your Applet need not sign up themselves with 50+ bookstores as affiliates. They use your accounts, and you track internally to figure out where various referral fees came from. They get one quarterly cheque from you, if the amount is above some minimum. Be aware that bookstores won’t necessarily provide you with detailed, timely accurate statements. The statements won’t track which site generated the sale either. Reconciliation is a major headache.

ISBN

The ISBN consists of 9 digits plus one check digit (0..9 or X). To calculate the check digit you must multiply the last digit of the true number by 2, the last but 1 by 3 etc. and add these results. The number needed to fill this sum to the next multiple of 11 is the check digit. If it is 10, the check digit is replaced by the letter 'X' (historically correct of course). In case the user mistypes an ISBN, (e.g. by transposing two digits) you want to explain that to him, rather than misleading him by telling him no one has the book in stock. You can read up on the rules for calculating the expected check digit.

Here is an example valid ISBN 0201479508. Here is how you ensure that it is valid.

ISBNs are sometimes written with dashes, breaking them up into variable length fields, much like class A, B, C IP addresses. For all practical purposes, you can ignore dashes and just remove them. However, if you are a perfectionist and want to display them properly you can read up on the rules . For code you can cannibalise to verify checkdigits and insert dashes, see the ISBN Amanuensis .

How does this work under the covers?

Unsigned Applets are not allowed to go shopping, because the sandbox security mechanism stops them from talking to any server except the one they were loaded from. A signed Applet, however could. Alternatively, unsigned Applets could could ask the server for the book pricing information. A servlet or application on the server is allowed to go comparison shopping. It can keep this information reasonably up to date. It need not comparison shop more than once per day per book. It need not comparison shop about a book no one has asked about recently. So you probably would implement this without any Java in the client, just using a servlet, though you might experiment with an Applet since it requires no co-operation from your ISP to let it run.

You need a very simple database of book information, possibly a Hashtable, BTree or SQL lookup by ISBN. This database is kept on the server. You can access it via JDBC, CGI or a servlet talking HTTP or raw sockets. At night the server goes shopping, getting fresh prices on the most popular items first, making sure to hop from store to store so as not to put an undue load on any one store. Eventually there may be a protocol for stores to notify you of price or availability changes so you don’t need to pester them with nightly polls.

You want to avoid polling any more frequently than absolutely necessary to remain on good terms with the book stores. Reduce polling frequency if the store does not carry the book. Reduce polling frequency if the price has not changed in a long time. Reduce the polling frequency if no other books at the store have recently changed prices. Reduce polling frequency if the book is not popular.

If you want to get fancy, you can use cookies to track your customers, mainly so you know what country/state/province they live in to compute shipping charges and taxes accurately. See the list of country codes . For a simple version, you might leave taxes and shipping out. However, you need that information to properly comparison shop. It can be hard to worm it out of a book store owner before committing to purchase.

The hardest part of this project is gathering the price information in many formats from many stores. The interfaces you are dealing with were designed for humans, not computers. They may change at any time. Before you get heavily into that, prototype the idea with fake or hand calculated data. Smooth the rough edges off your user interface, simulate the delays and see if the idea is acceptably quick, and whether end users love or hate it. It may be a licence to print money or a black hole for it. Perhaps some bookstores offer computer friendly price and availability lookup interfaces.

Invoking HTML

To recommend a book, you just need add three lines of standard HTML to your webpage giving the ISBN, formatted or unformatted of the book. You don’t need to provide title, author or book cover GIF/JPG. The Applet automatically deals with finding and displaying a book cover image, the title, the author and the formatted ISBN. A link to a book using Javascript might look like this:

<!--Esperanto Dictionary-->
<script type="text/javascript" language="javascript" src="http://bookdirect.com/price?cust=canadianmindprod&isbn=0960068880"> </script>
or using Java, like this:

The book cover *.gifs/jpgs could be automatically plucked from bookstores, cached on a central server, cached on the local server, cached on local hard disk or cached in the browser. A simpler version would just look on the local server for the GIF, and provide a dummy one if none were available, e.g. just giving the title of the book in large type, on a coloured background.

Because it is so little work to recommend a book, people might be much more willing to add such links. They are easier to set up than a traditional link, which requires custom gobbledegook like this:

You could use such an Applet to raise money for your favourite charity. All you need do is provide for a variable *.jpg to be displayed that explains how the generated revenue is spent.

Book Animator

Now lets take that one step further. Instead of providing just one ISBN, provide a list, either embedded in the HTML on in a file you upload to your website. Now the Applet can do a number of things:
  1. Randomly display a different book each time it is loaded.
  2. Change the displayed book every 10 seconds.
  3. Allow the user to scroll through the suggested books, along with your comments about them.
  4. Display the books 4 at a time, and allow scrolling.
  5. Display banner ads from Amazon about specials etc.
  6. It could provide direct links to the search engines or other popular parts of Amazon.
Now it takes only 10 keystrokes to add one more book to your list of recommendations. This should greatly encourage you to add lots of recommended books to your website.

You Don’t Need To Start From Scratch

I use a crude version of this amanuensis right now to generate the links on the CMP site. You are welcome to the source code. I will release it as a shareware product once I add the following features:

  1. Ability to lay out several books in a grid. Doing this by hand is very tedious and error-prone.
  2. Ability to get the images, titles and authors automatically from the bookstore websites. You can use the ImageInfo class part of the CMP business classes to automatically find out the width and height.

The Competition

There are some comparison shoppers out there already, such as mySimon, but this would be quicker since normally it would have recent prices already on file on a given narrow class of books e.g. Java.

Since I wrote up this project many book pricers have sprung up and faded away. See the list. None of them have been willing to share the proceeds with people who link to them which gives no incentive to link to them.

You also need a way to bulk refresh any generated HTML by extracting the variable data and rerunning the generator. See the HTML macros project Which could be used to generate or regenerate complex HTML.


CMP_homejump to top
CMP logo
feedback Please email your feedback for publication, errors, omissions, broken/redirected link reports
and suggestions to improve this page to Roedy Green : feedback email
made with CSS
HTML Checked!
ICRA ratings logo
mindprod.com IP:[65.110.21.43]
Your face IP:[38.103.63.18] The information on this page is for non-military use only.
You are visitor number 5,068. Military use includes use by defence contractors.
You can get a fresh copy of this page from: or possibly from your local J: drive (Java virtual drive/Mindprod website mirror)
http://mindprod.com/project/bookrefer.html J:\mindprod\project\bookrefer.html