Steps: 

  (a) create a context (whatever)
  (b) go there and create a folder (permanent) 
  (c) in permanent create inventory.txt
  (d) now create the rest of the context (in whatever)
      -- create WEB-INF
      -- create src, lib and classes in WEB-INF
  (e) move into whatever/WEB-INF/src
  (f) create Four.java, Quote.java, Model.java and Test.java 
  (g) compile everything in src: javac -d ../classes *.java
  (h) move into classes and create the database:
      java junior.Four ../../permanent/inventory.txt
  This step creates the database. 
  (i) create web.xml that deploys Test.java 
  (j) call /model/test and play with it. 

These steps in detail: 

  678  cd
  679  cd second-server/
  680  cat .tomcat-settings
  681  cat ~/c212-workspace/.tomcat-settings
  682  clear
  683  source .tomcat-settings
  684  echo $CATALINA_HOME
  685  clear
  686  cd
  687  cd c212-workspace/
  688  echo $CATALINA_HOME
  689  source .tomcat-settings
  690  echo $CATALINA_HOME
  691  cd
  692  clear
  693  cd second-server/
  694  echo $CATALINA_HOME
  695  source .tomcat-settings
  696  echo $CATALINA_HOME
  697  pwd
  698  cd $CATALINA_HOME
  699  cd webapps/
  700  ls
  701  mkdir whatever
  702  cd whatever/
  703  mkdir permanent
  704  cd permanent/
  705  nano -w inventory.txt
  706  ls -l
  707  cat inventory.txt
  708  pwd
  709  clear
  710  pwd
  711  ls -l
  712  cd ..
  713  pwd
  714  ls
  715  mkdir WEB-INF
  716  cd WEB-INF/
  717  mkdir classes
  718  cd ..
  719  mkdir lib
  720  mkidr src
  721  mkdir src
  722  cd src
  723  clear
  724  nano -w Four.java
  725  ls -l
  726  clear
  727  pwd
  728  nano -w Four.java
  729  pwd
  730  mkdir ../permanent/database
  731  cat Four.java
  732  javac -d ../classes/ *.java
  733  pwd
  734  clear
  735  pwd
  736  cd ..
  737  mv src/ WEB-INF/
  738  cd WEB-INF/
  739  cd src/
  740  javac -d ../classes/ *.java
  741  nano -w Quote.java
  742  clear
  743  ls -l
  744  javac -d ../classes/ *.java
  745  ls -ld ../../permanent/database/
  746  cd ..
  747  cd classes/
  748  ls -l
  749  pwd
  750  ls -l
  751  tree .
  752  java junior.Four ../../permanent/inventory.txt
  753  pwd
  754  ls $CATALINA_HOME/webapps/whatever/permanent
  755  clear
  756  pwd
  757  rmdir ../../permanent/database/
  758  java junior.Four ../../permanent/inventory.txt
  759  clear
  760  pwd
  761  cd ..
  762  pwd
  763  tree whatever/
  764  clear
  765  pwd
  766  ls
  767  cd whatever/
  768  cd permanent/
  769  ls -l
  770  file database
  771  file inventory.txt
  772  clear
  773  pwd
  774  cd ../WEB-INF/src/
  775  ls -l
  776  nano -w Model.java
  777  cd ..
  778  cd ../permanent/
  779  clear
  780  pwd
  781  ls -l
  782  cd ../WEB-INF/
  783  cd src
  784  clear
  785  pwd
  786  ls -l
  787  nano -w Model.java
  788  cat Model.java
  789  javac -d ../classes/ *.java
  790  clear
  791  pwd
  792  ls -l
  793  cd ../classes/
  794  ls
  795  tree .
  796  cd ../src
  797  nano -w Test.java
  798  javac -d ../classes/ *.java
  799  cd ..
  800  pwd
  801  clear
  802  pwd
  803  ls -l
  804  cd ..
  805  ls
  806  mv lib/ WEB-INF/
  807  cd WEB-INF/
  808  ls -l
  809  nano -w web.xml
  810  clear
  811  pwd
  812  cat web.xml
  813  clear
  814  date
  815  cd ..
  816  cd permanent/
  817  ls -l
  818  clear
  819  ps -ef | grep kowa
  820  history
  821  cd
  822  cd c212
  823  cd c212-workspace/
  824  source .tomcat-settings
  825  cd $CATALINA_HOME
  826  cd webapps/
  827  cd apple/
  828  ls
  829  cd WEB-INF/
  830  cd classes/
  831  ls
  832  ls -l
  833  javac Lille.java
  834  ls -l
  835  nano -w Lille.java
  836  history
[kkowala@silo classes]$



I work in Katherine's account on her second server: 

[kkowala@silo ~]$ cd second-server/
[kkowala@silo second-server]$ echo $CATALINA_HOME
/u/kkowala/c212-workspace/apache-tomcat-7.0.35
[kkowala@silo second-server]$ source .tomcat-settings
[kkowala@silo second-server]$ echo $CATALINA_HOME
/u/kkowala/second-server/apache-tomcat-7.0.35
[kkowala@silo second-server]$

I create a whatever context and a permanent folder:

[kkowala@silo second-server]$ pwd
/u/kkowala/second-server
[kkowala@silo second-server]$ cd $CATALINA_HOME
[kkowala@silo apache-tomcat-7.0.35]$ cd webapps/
[kkowala@silo webapps]$ ls
cricket  docs  examples  host-manager  manager  ROOT
[kkowala@silo webapps]$ mkdir whatever
[kkowala@silo webapps]$ cd whatever/
[kkowala@silo whatever]$ mkdir permanent
[kkowala@silo whatever]$ cd permanent/
[kkowala@silo permanent]$

In this folder I create a simple text file:

[kkowala@silo permanent]$ nano -w inventory.txt
[kkowala@silo permanent]$ ls -l
total 4
-rw------- 1 kkowala students 434 Jul 20 14:52 inventory.txt
[kkowala@silo permanent]$ cat inventory.txt
Seneca
Time discovers truth.
Steven Wright
How do you know when you're out of invisble ink?
Marilyn Monroe
It's not true I had nothing on. I had the radio on.
Thomas Neil
Of those who say nothing few are silent.
Oscar Wilde
The only way to get rid of temptation is to yield to it.
Donald J Trump
Who is General Failure and why is he reading my hard disk?
Steven Wright
I almost had a psychic girlfriend but she left me before we met.
[kkowala@silo permanent]$ pwd
/u/kkowala/second-server/apache-tomcat-7.0.35/webapps/whatever/permanent
[kkowala@silo permanent]$

Now I create the rest of the context and get started with compiling:

[kkowala@silo permanent]$ pwd
/u/kkowala/second-server/apache-tomcat-7.0.35/webapps/whatever/permanent
[kkowala@silo permanent]$ ls -l
total 4
-rw------- 1 kkowala students 434 Jul 20 14:52 inventory.txt
[kkowala@silo permanent]$ cd ..
[kkowala@silo whatever]$ pwd
/u/kkowala/second-server/apache-tomcat-7.0.35/webapps/whatever
[kkowala@silo whatever]$ ls
permanent
[kkowala@silo whatever]$ mkdir WEB-INF
[kkowala@silo whatever]$ cd WEB-INF/
[kkowala@silo WEB-INF]$ mkdir classes
[kkowala@silo WEB-INF]$ cd ..
[kkowala@silo whatever]$ mkdir lib
[kkowala@silo whatever]$ mkdir src
[kkowala@silo whatever]$ cd src
[kkowala@silo src]$

I am in src and I will create my first few Java programs here: 

[kkowala@silo src]$ nano -w Four.java
[kkowala@silo src]$ ls -l
total 4
-rw------- 1 kkowala students 584 Jul 20 14:57 Four.java
[kkowala@silo src]$

Customize the file: 

[kkowala@silo webapps]$ pwd
/u/kkowala/second-server/apache-tomcat-7.0.35/webapps
[kkowala@silo webapps]$ tree whatever/
whatever/
├── lib
├── permanent
│   ├── database
│   └── inventory.txt
└── WEB-INF
    ├── classes
    │   └── junior
    │       ├── Four.class
    │       └── Quote.class
    └── src
        ├── Four.java
        └── Quote.java

6 directories, 6 files
[kkowala@silo webapps]$

Now the database has been created. 

[kkowala@silo webapps]$ pwd
/u/kkowala/second-server/apache-tomcat-7.0.35/webapps
[kkowala@silo webapps]$ ls
cricket  docs  examples  host-manager  manager  ROOT  whatever
[kkowala@silo webapps]$ cd whatever/
[kkowala@silo whatever]$ cd permanent/
[kkowala@silo permanent]$ ls -l
total 8
-rw------- 1 kkowala students 851 Jul 20 15:08 database
-rw------- 1 kkowala students 434 Jul 20 14:52 inventory.txt
[kkowala@silo permanent]$ file database
database: Java serialization data, version 5
[kkowala@silo permanent]$ file inventory.txt
inventory.txt: ASCII text
[kkowala@silo permanent]$

It would be good if we had the model working already. 

[kkowala@silo permanent]$ pwd
/u/kkowala/second-server/apache-tomcat-7.0.35/webapps/whatever/permanent
[kkowala@silo permanent]$ ls -l
total 8
-rw------- 1 kkowala students 851 Jul 20 15:08 database
-rw------- 1 kkowala students 434 Jul 20 14:52 inventory.txt
[kkowala@silo permanent]$

So I add the Model.java file and modify it:

[kkowala@silo src]$ pwd
/u/kkowala/second-server/apache-tomcat-7.0.35/webapps/whatever/WEB-INF/src
[kkowala@silo src]$ ls -l
total 12
-rw------- 1 kkowala students  582 Jul 20 15:02 Four.java
-rw------- 1 kkowala students 1729 Jul 20 15:14 Model.java
-rw------- 1 kkowala students  528 Jul 20 15:05 Quote.java
[kkowala@silo src]$ nano -w Model.java
[kkowala@silo src]$ cat Model.java
package junior;

import java.io.*;
import java.util.*;

public class Model {
  private Model() {
    try {
      this.reset();
    } catch (Exception e) {

    }
  }
  private static Model instance = new Model();
  public static Model getInstance() {
    return instance;
  }
  Integer nextAvailableId = 0;
  Map<Integer, Quote> a;

  String pathToDatabase = "/u/kkowala/second-server/apache-tomcat-7.0.35/webapps/whatever/permanent/database";

  synchronized void reset() throws Exception {
    FileInputStream fis = new FileInputStream(pathToDatabase);
    ObjectInputStream ois = new ObjectInputStream(fis);
    this.a = (HashMap<Integer, Quote>) ois.readObject();
    ois.close();
    this.nextAvailableId = (this.a.keySet()).size();
  }
  Quote randomQuote() {
    ArrayList<Quote> a = new ArrayList<Quote>();
    for (Integer key : this.a.keySet()) {
      a.add(this.a.get(key));
    }
    return a.get((int)(Math.random() * a.size()));
  }
  Quote retrieveQuote(Integer id) {
    return a.get(id);
  }
  ArrayList<Quote> retrieveAll() {
    ArrayList<Quote> a = new ArrayList<Quote>();
    for (Integer key : this.a.keySet()) {
      a.add(this.a.get(key));
    }
    return a;
  }
  synchronized void delete(Integer id) {
    this.a.remove(id);
  }
  synchronized void addQuote(String author, String quote) {
    Integer id = nextAvailableId++;
    this.a.put(id, new Quote(id, author, quote));
  }
  synchronized void updateQuote(Integer id, Quote quote) {
    this.a.put(id, quote);
  }
  synchronized void save() throws Exception {
    FileOutputStream fout = new FileOutputStream(pathToDatabase);
    ObjectOutputStream oos = new ObjectOutputStream(fout);
    oos.writeObject(this.a);
  }
}
[kkowala@silo src]$ javac -d ../classes/ *.java
Picked up _JAVA_OPTIONS: -Xms512m -Xmx512m
Note: Model.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
[kkowala@silo src]$

I changed the path to database and the line that accesses it. 

[kkowala@silo WEB-INF]$ pwd
/u/kkowala/second-server/apache-tomcat-7.0.35/webapps/whatever/WEB-INF
[kkowala@silo WEB-INF]$ cat web.xml
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app
  PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
  "http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
  <servlet>
    <servlet-name>model</servlet-name>
    <servlet-class>junior.Test</servlet-class>
  </servlet>
  <servlet-mapping>
    <servlet-name>model</servlet-name>
    <url-pattern>/model/test</url-pattern>
  </servlet-mapping>
</web-app>
[kkowala@silo WEB-INF]$

Elise Misato Daniel R Katherine Jillian Kevin Tao Rafa Iris Garrett Yibo 
Khalea Patrick Keiland Noah Nicholas Daniel C John Taylor Ryan Bihan Jiang