Let's install Tomcat. 

Your host will be silo.cs.indiana.edu, your port: ... ?

Ports are listed at:

http://www.cs.indiana.edu/classes/c212-dgerman/fall2012/students.html

Something wrong with those let dgerman know. 

Homework this week:

http://www.cs.indiana.edu/classes/c212-dgerman/fall2012/hwEight.html

Reading assignment for next week:

http://www.cs.indiana.edu/~dgerman/sum2012/patterns.pdf

My username: acozad, my port: 11262 (along with 11263).

Let me start installing my server. 

1. Copy the compressed archive from

   /l/www/classes/a348/sum2006/software/apache-tomcat-5.5.17.tar.gz

2. Uncompress and unarchive, delete the archive, move into folder. 

3. Look around, then move into conf.

4. In conf you find server.xml which you should mv to server.xml-distr for reference.

5. Copy server-minimal.xml to server.xml and make three changes. 

6. Mine looks like this when I am done:

[acozad@silo conf]$ pwd
/u/acozad/apache-tomcat-5.5.17/conf
[acozad@silo conf]$ cat server.xml
<Server port="11263" shutdown="SHUTDOWN">

  <GlobalNamingResources>
    <!-- Used by Manager webapp -->
    <Resource name="UserDatabase" auth="Container"
              type="org.apache.catalina.UserDatabase"
       description="User database that can be updated and saved"
           factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
          pathname="conf/tomcat-users.xml" />
  </GlobalNamingResources>

  <Service name="Catalina">
    <Connector port="11262" />

    <Engine name="Catalina" defaultHost="localhost">
      <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
             resourceName="UserDatabase" />
      <Host name="localhost" appBase="webapps" />
    </Engine>

  </Service>
</Server>
[acozad@silo conf]$ diff server.xml server-minimal.xml
1c1
< <Server port="11263" shutdown="SHUTDOWN">
---
> <Server port="8005" shutdown="SHUTDOWN">
13c13,16
<     <Connector port="11262" />
---
>     <Connector port="8080" />
>
>     <!-- This is here for compatibility only, not required -->
>     <Connector port="8009" protocol="AJP/1.3" />
[acozad@silo conf]$

7. I need to set up three environment variables. 

Remember Lab Nine Notes from Spring 2011:

http://www.cs.indiana.edu/classes/c212/spr2011/notes/labNotes09.html

These are the settings:

JAVA_HOME=/usr/lib/jvm/java-1.6.0-sun.x86_64
export JAVA_HOME

CATALINA_HOME=/u/acozad/apache-tomcat-5.5.17
export CATALINA_HOME

CLASSPATH=.:$CATALINA_HOME/common/lib/servlet-api.jar
export CLASSPATH

Put them at the end of ~/.bash_profile and source the file.

8. Verify that the variables are available to you, then start the server. 

Before you do that you can also use netstat to check ports assigned are free. 

9. Check the server at http://silo.cs.indiana.edu:11262

10. A really meaningful step at this stage would be to shut it down. 

11. Remember my advice: never start the server when it's running. 

12. Check server is down and add yourself as a manager. 

[acozad@silo conf]$ pwd
/u/acozad/apache-tomcat-5.5.17/conf
[acozad@silo conf]$ ls -ld tomcat-users.xml
-rw------- 1 acozad students 369 Nov  1 10:15 tomcat-users.xml
[acozad@silo conf]$ grep amy tomcat-users.xml
  <user username="amy" password="d1v1n9" roles="manager"/>
[acozad@silo conf]$

That's how it looks for Amy anyway. 

13. Restart your server and from the main page become manager. 

14. Look at all those contexts with a feeling of pride. 

We will create a new one shortly. 

Connect to

http://www.cs.indiana.edu/classes/c212-dgerman/fall2012/lectureTwenty.html

Then create the folders indicated in that diagram and put the files in them.

15. Remember that your port number is 11262 so make three changes: 

Here's one change:

[acozad@silo classes]$ pico -w Chat.java
[acozad@silo classes]$ grep -n 11262 Chat.java
36:       + "codebase=\"http://silo.cs.indiana.edu:11262/chat\"\n"
[acozad@silo classes]$

Compile the classes then move up two folders.

Here are the other two changes there:

[acozad@silo chat]$ ls -l
total 12
-rw------- 1 acozad students 2386 Nov  1 10:24 ChatApplet.java
-rw------- 1 acozad students 1828 Nov  1 10:25 HttpMessage.java
drwx------ 4 acozad students 4096 Nov  1 10:27 WEB-INF
[acozad@silo chat]$ pico -w ChatApplet.java
[acozad@silo chat]$ grep -n 11262 *.java
ChatApplet.java:55:              new URL("http://silo.cs.indiana.edu:11262/chat/servlet/ChatServlet");
ChatApplet.java:66:              new URL("http://silo.cs.indiana.edu:11262/chat/servlet/ChatServlet");
[acozad@silo chat]$

Compile the code notice but ignore the warnings. 

16. Check the chat system on-line:

http://silo.cs.indiana.edu:11262/chat/servlet/Chat

17. That's about it for today. See you in lab. 

--