USHOP 2.0



Now that uShop has over 65 Java .class files, you may want to consider different options for managing them on your web site. This reference page describes the various ways that you can arrange the uShop .class files on your site in order to keep them organized and easy to maintain.

When it comes to the uShop's shopping cart data, it is important that the browser thinks that all of the .class files were loaded from the same URL. This means that there are a couple options for arranging the .class and .html files on your server:


Option 1: Put All Of The HTML Pages And All Of The CLASS Files In The Same Directory

This is obviously the easiest way to setup your store and is a totally valid solution, however, if your store has alot of HTML pages, then this one directory can get quite large. You may be able to reduce the size of this directory by only putting the .class files that your store uses in this directory. That is, instead of putting all 65+ .class files in the directory, just put the uShopInput applets and the uShopOrder applets that you are using in your store. Be sure to also include all of the required uShop .class files - as listed in the "Required Applets" section of the uShop 2.0 Applet Reference.


Option 2: Put All Of The CLASS Files In Their Own Directory And Then Reference That Directory From The HTML Pages In Other Directories

You can get a little more organized by creating a "classes" directory and putting all of the uShop .class files in that one directory. Then you can arrange your store's HTML pages in other directories, and use the CODEBASE parameter to specify where the .class files are located.

For example, lets say you have this directory structure:


<your main html directory>
     |
     |
     ----- "classes" (a subdirectory containing all of the uShop applets)
     |
     |
     ----- "directory1" (use codebase="../classes/" to refer to the classes directory)
     |
     |
     ----- "directory2" (use codebase="../classes/" to refer to the classes directory)
     |
     |
     ----- "directory3" (use codebase="../classes/" to refer to the classes directory)


Then you could reference the "classes" directory from the other directories, by setting the CODEBASE parameter in all your applets to "../classes/", such as in the first line of this applet:

<APPLET CODE = "uShopInputStandard.class" codebase="../classes/" WIDTH=450 HEIGHT=35>
<PARAM NAME=id          VALUE="F00002">
<PARAM NAME=showid      VALUE="YES">
<PARAM NAME=name        VALUE="Othello">
<PARAM NAME=description VALUE="softbound">
<PARAM NAME=options     VALUE="NONE">
<PARAM NAME=weight      VALUE="1">
<PARAM NAME=price       VALUE="$ 5.95">
<PARAM NAME=background  VALUE="255,204,153">
</APPLET>

Note when using this relative path to the "classes" directory, it is very important to keep all of your directories on the same directory level so that the CODEBASE that you use is exactly the same in all of your applets. That is, the browser will not necessarily interpret "../classes/" and "../../classes/" as the to the same URL -- even if they actually are. So just to make sure it will work on most browsers, keep the codebase of all of your applets EXACTLY the same.


A Note For Supporting Older Browsers

Referencing the "classes" directory from HTML pages in different directories by using a relative CODEBASE (as described above) will work on most new browsers (Netscape 4.0 and later and IE 4.0 and later) - however, some older browsers such as Netscape 3.0 will have a problem if you use a relative CODEBASE and more than one store directory. So if you want to make sure your store supports older browsers, then there are two solutions:

Supporting The CODEBASE Parameter With Older Browsers - Solution 1

One solution to ensuring that the CODEBASE work properly with older browsers is to just have two directories - a "classes" directory and a "store" directory. The "classes" directory is used to contain all of the uShop .class files (as described above) - however, instead of seperating all of the store pages into different directories, all of the store pages are contained in the same directory - As illustrated below:

<your main html directory>
     |
     |
     ----- "classes" (a subdirectory containing all of the uShop applets)
     |
     |
     ----- "store" (all store pages go in this directory)
                   (use codebase="../classes/" to refer to the classes directory)


This sort of directory structure will allow you to use a relative CODEBASE with older browsers such as Netscape 3.0.

Supporting The CODEBASE Parameter With Older Browsers - Solution 2

The other solution to ensuring that the CODEBASE work properly with older browsers is to just use the full URL of the "classes" directory as the CODEBASE in all of your applets. That is, you could locate your store pages in any directories/directory structure that you want, and just set the CODEBASE to the full URL of your "classes" directory, such as in the first line of this applet:

<APPLET CODE = "uShopInputStandard.class" codebase="http://www.yourdomain.com/classes/" WIDTH=450 HEIGHT=35>
<PARAM NAME=id          VALUE="F00002">
<PARAM NAME=showid      VALUE="YES">
<PARAM NAME=name        VALUE="Othello">
<PARAM NAME=description VALUE="softbound">
<PARAM NAME=options     VALUE="NONE">
<PARAM NAME=weight      VALUE="1">
<PARAM NAME=price       VALUE="$ 5.95">
<PARAM NAME=background  VALUE="255,204,153">
</APPLET>

The only disadvantage to using the full URL as the CODEBASE, is that it prevents you from developing and testing your store pages locally - without being connected to the internet. (However, if you do connect to the internet, then you still can develop/test your store pages locally).