INSTRUCTIONS FOR GETTING STARTED IN THE ECOMMERCE COURSE



STEP 1: FIRST INSTALL AND TEST ACCESS TO JAVA


STEP 2: INSTALL THE SERVLET KIT (JSDK.JAR) AND ADJUST YOUR CLASSPATH TO INCLUDE THIS LIBRARY.


STEP 3: INSTALL THE JIGSAW WEBSERVER AND TEST DOCUMENT ACCESS

  • Jigsaw is a W3C webserver that can handle servlets. It is written entirely in Java - with full source available.
  • Jigsaw can be downloaded from www.w3c.org/jigsaw or copied from my directory. To copy from me:
        % cp ~simha/java/ecom/jigsaw.tar.gz ~/java/.
        % cd ~/java
        % gunzip jigsaw.tar.gz
        % tar -xvf jigsaw.tar
     
    This will create a directory called Jigsaw.
  • Check to make sure you got the all-important library with it:
        % ls ~/java/Jigsaw/Jigsaw/classes/jigsaw.zip
     
  • Next, add the jigsaw library to the CLASSPATH:
       setenv CLASSPATH /usr/local/jdk1.2/lib:$HOME/java/JSDK2.0/lib/jsdk.jar:$HOME/java/Jigsaw/Jigsaw/classes/jigsaw.zip:.
     
  • Then, go to the Jigsaw install directory and install it:
        % cd ~/java/Jigsaw/Jigsaw
        % java Install
     
    This completes the installation, but not the configuration.
  • Next, you will need to configure the webserver before running it. Go to the configuration directory
        % cd ~/java/Jigsaw/Jigsaw/config/
     
    and edit the files admin-server.props and http-server.props.
    • First, edit admin-server.props:
      • Edit every line that has a path and set the path correctly.
      • For example:
                 org.w3c.jigsaw.propfile=/home/joe/java/Jigsaw/Jigsaw/config/admin-server.props
                 org.w3c.jigsaw.config=/home/joe/java/Jigsaw/Jigsaw/configadm
                 org.w3c.jigsaw.root=/home/joe/java/Jigsaw/Jigsaw
         
      • Set the admin port number WHICH YOU HAVE BEEN ASSIGNED. For example, suppose you have been assigned 8501, set
                 org.w3c.jigsaw.port=8501
         
    • Next, edit the file http-server.props:
      • Edit every line that has a path and set the path correctly.
      • For example:
                 org.w3c.jigsaw.trashdir=/home/joe/java/Jigsaw/Jigsaw/trash
                 org.w3c.jigsaw.propfile=/home/joe/java/Jigsaw/Jigsaw/config/http-server.props
                 org.w3c.jigsaw.config=/home/joe/java/Jigsaw/Jigsaw/config
                 org.w3c.jigsaw.root=/home/joe/java/Jigsaw/Jigsaw
                 org.w3c.jigsaw.servlet.servlet-log-file=/home/joe/java/Jigsaw/Jigsaw/logs/servlets
         
      • Now decide where you want to keep the root of the document directory (your homepage). Suppose you create a directory called /home/joe/htdocs for your document directory. Then, set
                 org.w3c.jigsaw.space=/home/joe/htdocs
         
      • Place any HTML file in this directory and call it Overview.html
      • Set the webserver port number WHICH YOU HAVE BEEN ASSIGNED. For example, suppose you have been assigned 8502, set
                 org.w3c.jigsaw.port=8502
         
    Now Jigsaw is ready to be fired up.
  • Let's do a test run:
    • First, fire up netscape and keep it ready:
            % netscape&
        
    • Next, launch the webserver (from any directory):
            % java org.w3c.jigsaw.Main -root /home/joe/java/Jigsaw/Jigsaw
       
      This should run the webserver, which will listen at port 8502 (or whatever you had used as a port number above).
    • Now test it, by entering the following URL in netscape:
            http://localhost:8502
       
    • This should fetch the Overview.html file in the htdocs directory and display it in netscape.
    • If it doesn't work, don't proceed any further without getting up to this point.
    • About URLs:
      • You can also use the URL with the IP address of the machine, as in:
                 http://128.14.9.82:8502
          
        as long as you append the port number.
      • All your URLs must contain the port number. This is not really a user-friendliness issue since, once the homepage is reached, the only thing a user does is click. On the other hand, some (but not all) of your HTML will contain your special port number. This is the price to be paid for allowing everyone to run their own webservers.
  • Instead of typing the whole line
          % java org.w3c.jigsaw.Main -root /home/joe/java/Jigsaw/Jigsaw
     
    everytime you want to run the webserver, create a shortcut (alias) in your .cshrc file:
          alias jigsaw "java org.w3c.jigsaw.Main -root /home/joe/java/Jigsaw/Jigsaw"
     
    This way, you can simply type:
          % jigsaw 
     
    to run it.
  • Administering the webserver:
    • There is a separate tool used for adminstrating the webserver called Jigadmin.
    • This runs as a standalone java application.
    • Try it out:
            % java org.w3c.jigadm.Main -root /home/joe/java/Jigsaw/Jigsaw http://felix:8501
       
      (Note: use your assigned admin port number of course).
    • This should bring up the JigAdmin tool, which will ask for a password. The username is simply admin and password is also admin You can change the password later, although it is really not necessary since nobody else can access your directories.
    • You need to set up a servlet directory before proceeding.
  • Create a shortcut.
    • Edit your .cshrc file to create a shortcut for jigadmin:
            alias jigadmin "java org.w3c.jigadm.Main -root /home/joe/java/Jigsaw/Jigsaw http://felix:8501"
       
    • This will allow you to type "jigadmin" instead of the whole line.


STEP 4: CONFIGURE JIGSAW TO RUN SERVLETS AND TEST


STEP 5: INSTALL MSQL AND TEST

  • mSQL is a commercial Unix-dbase package created by Hughes, Australia. It's free (including source) for all-but commercial use; there are license agreements (reasonably priced) for commercial use, i.e., including it in a product.

    mSQL supports a subset of SQL, comes with a tiny admin tool, an SQL interpreter, a script language, and a web-like scripting language for server-side includes in webpages. They claim strong performance with small data sets and reasonable performance with large data sets.

    mSQL and mSQL documentation can be found at: http://www.hughes.com.au

    You can copy mSQL from my directory. The manual will be placed on the course website.

  • We will now install mSQL:
    • Copy over the file msql-2.0.9.tar.gz and un-tar
            % cp ~simha/java/ecom/msql-2.0.9.tar.gz ~/java/.
            % gunzip msql-2.0.9.tar.gz
            % tar -xvf msql-2.0.9.tar
        
    • This will create a directory called msql-2.0.9/
  • Next, compile mSQL:
    • Go to the main directory:
            % cd ~simha/java/ecom/msql-2.0.9/
       
    • Now, build the target directory by typing "make target"
            % make target
        
      This script discovers your machine and environment and creates a configuration for compilation. The output to the screen is something like:
               Making target directory for Solaris-2.6-Sparc
      
               Building directory tree.
                  Adding common
                  Adding conf
                  Adding lang-common
                  Adding lite
                  Adding makedepend
                  Adding makegen
                  Adding msql
                  Adding regexp
                  Adding tests
                  Adding tests/rtest.src
                  Adding w3-msql
                  Adding w3-msql/tests
      
               Adding sym-links
               ............................................................
               ............................................................
      
               Build of target directory for Solaris-2.6-Sparc complete
      
        
    • Let's assume that your machine is running the Solaris OS.
    • cd to the /targets directory and then to the particular OS directory that was created:
             % cd targets/Solaris-2.6-Sparc/
        
    • Execute "setup":
             % setup
       
      The output is something like:
              Starting configuration of mSQL 2.
              creating cache ./config.cache
              checking for gcc... gcc
              checking whether the C compiler (gcc  ) works... yes
              checking whether the C compiler (gcc  ) is a cross-compiler... no
         
              ... [stuff left out]
      
              Ready to build mSQL.
              You may wish to check "site.mm" although the defaults should be
              fine.  When you're ready, type  "make all" to build the software
      
        
    • Next, decide where you want the installation. Usually, this is a bin directory off of the main directory:
      n
              msql-2.0.9/bin
        
    • Create the bin directory yourself:
             % cd ~/java/msql-2.0.9/
             % mkdir bin
        
    • Now edit the site.mm file to set the INST_DIR to this bin directory, e.g.,
              INST_DIR= /home/joe/java/msql-2.0.9/bin
        
    • Type make all to compile:
            % make all
        
      This will take time and produce a lot of output, something like:
             Regenerating Makefile.
             ......................................................
             Done.
      
             Starting make for mSQL-2
      
             --> [common] directory  
       
             Regenerating Makefile.
             .....................................
      
             ...[stuff left out]
      
             Make of mSQL-2 complete.
             You should now install mSQL-2 using make install
      
        
  • Next, install the executables by typing make install
        % make install
      
    This should produce output like:
           Starting install for mSQL-2
    
           ...[stuff left out]
    
           Installation of mSQL-2 complete.
      
  • Now the executable is ready and mSQL needs to be configured to run:
    • Go to the installation directory and edit the file msql.conf:
      • Here, you set the username under which it runs, the admin username (joe) and port number for clients (and JDBC). The default is 1114, but that should be changed to your THIRD assigned port number (say, 8114) because to use 1114 you need to be root.
      • Next, change the remote access part to True under the system parameters (Otherwise, JDBC can't connect).
    • Check the installation directory ~/java/msql-2.0.9/bin (that you specified) to look for the various executables such as msql2d, msql etc. If you see them, the installation is complete.
    • NOTE:
      • msql2d is actually the dbase server (it'll run as daemon).
      • msql is an interpreter that reads SQL-like commands.
      • msqladmin is an admin program for mSQL.
  • Running mSQL:
    • Go to the ~/java/msql-2.0.9/bin directory containing the msql2d executable and fire up the daemon:
             % msql2d &
        
    • Create a "test" database using msqladmin: % msqladmin create testdb A dbase needs to be created before you can use it.
    • Test it:
             % msql testdb
             msql> create table testtable (age integer) \g
        
      This will create a table that you can work with, e.g.,
             msql> select * from testtable \g
        
    • NOTE: every mSQL command must end with a "\g" (backslash followed by g).
    • The daemon will run continuously as long as the machine is up (you don't have to be logged in).
  • Shutting it down:
    To shutdown the server, type:
         
      % msqladmin shutdown
      
  • Learning more mSQL administration:
    - Simply typing msqladmin will list commands.
  • Using the msql interpreter:
    • You can type in SQL directly. To end an SQL statement use "\g". To quit type "\q."
    • There is a way to import data using the msqlimport tool.
  • A smarter way to create data:
    • Create a plain text file containing your various insert commands.
    • For example, copy over the file bank_schema.sql from me and examine its contents:
             % cp ~simha/java/ecom/bank_schema.sql
        
    • To create the bank database, first use msqladmin to create a new database (a new collection of tables, separate from other collections of tables):
             % msqladmin create bank
        
    • Now, simply feed the file to msql:
             % msql bank < bank_schema.sql
        
    • NOTE: do create this bank database, because we will use it below to test JDBC.
  • NOTE:
    • mSQL is single-user and therefore doesn't use passwords.
    • mSQL only supports a small subset of SQL (no nested SQL, for example).
    • mSQL does not support transaction processing, so you need to handle that yourself via threads in Java.


STEP 6: TEST JDBC VIA THE JDBC DRIVER