I work in Tomcat today.

I start modifying tomcat-users.xml in conf.

Here's the reason why:

http://silo.cs.indiana.edu:13755/manager/html

So we set something like this up: 

<role rolename="manager-gui"/>
<user username="abc" password="12345" roles="manager-gui"/>

So here's where we are at this stage: 

[niuqin@silo conf]$ pico -w tomcat-users.xml
[niuqin@silo conf]$ cat tomcat-users.xml
<?xml version='1.0' encoding='utf-8'?>
<tomcat-users>
  <role rolename="tomcat"/>
  <role rolename="role1"/>
  <role rolename="manager-gui"/>
  <user username="abc" password="12345" roles="manager-gui"/>
  <user username="both" password="tomcat" roles="tomcat,role1"/>
  <user username="role1" password="tomcat" roles="role1"/>
</tomcat-users>
[niuqin@silo conf]$ pwd
/u/niuqin/apache-tomcat-7.0.35/conf
[niuqin@silo conf]$

So here's how we stop and restart it:

[niuqin@silo conf]$ pico -w $CATALINA_HOME/webapps/ROOT/index.html
[niuqin@silo conf]$ ls -l
total 208
drwx------ 3 niuqin students   4096 Jul 14 17:23 Catalina
-rw------- 1 niuqin students  12128 Jan 10  2013 catalina.policy
-rw------- 1 niuqin students   6392 Jan 10  2013 catalina.properties
-rw------- 1 niuqin students   1394 Jan 10  2013 context.xml
-rw------- 1 niuqin students   3288 Jan 10  2013 logging.properties
-rw------- 1 niuqin students   6435 Jan 10  2013 old-server.xml
-rw------- 1 niuqin students    737 Jul 15 11:33 server.xml
-rw------- 1 niuqin students   1530 Jan 10  2013 tomcat-users.xml
-rw------- 1 niuqin students 162905 Jan 10  2013 web.xml
[niuqin@silo conf]$ pico -w tomcat-users.xml
[niuqin@silo conf]$ cat tomcat-users.xml
<?xml version='1.0' encoding='utf-8'?>
<tomcat-users>
  <role rolename="tomcat"/>
  <role rolename="role1"/>
  <role rolename="manager-gui"/>
  <user username="abc" password="12345" roles="manager-gui"/>
  <user username="both" password="tomcat" roles="tomcat,role1"/>
  <user username="role1" password="tomcat" roles="role1"/>
</tomcat-users>
[niuqin@silo conf]$ pwd
/u/niuqin/apache-tomcat-7.0.35/conf
[niuqin@silo conf]$ clear
[niuqin@silo conf]$ cd ../logs
[niuqin@silo logs]$ ls
catalina.2015-07-14.log  host-manager.2015-07-14.log  localhost.2015-07-15.log
catalina.2015-07-15.log  host-manager.2015-07-15.log  manager.2015-07-14.log
catalina.out             localhost.2015-07-14.log     manager.2015-07-15.log
[niuqin@silo logs]$ rm *
rm: remove regular file `catalina.2015-07-14.log'? y
rm: remove regular file `catalina.2015-07-15.log'? y
rm: remove regular file `catalina.out'? y
rm: remove regular empty file `host-manager.2015-07-14.log'? y
rm: remove regular empty file `host-manager.2015-07-15.log'? y
rm: remove regular file `localhost.2015-07-14.log'? y
rm: remove regular file `localhost.2015-07-15.log'? y
rm: remove regular empty file `manager.2015-07-14.log'? y
rm: remove regular empty file `manager.2015-07-15.log'? y
[niuqin@silo logs]$ /u/niuqin/apache-tomcat-7.0.35/bin/shutdown.sh
Using CATALINA_BASE:   /u/niuqin/apache-tomcat-7.0.35
Using CATALINA_HOME:   /u/niuqin/apache-tomcat-7.0.35
Using CATALINA_TMPDIR: /u/niuqin/apache-tomcat-7.0.35/temp
Using JRE_HOME:        /usr/lib/jvm/jre-1.7.0-openjdk.x86_64
Using CLASSPATH:       /u/niuqin/apache-tomcat-7.0.35/bin/bootstrap.jar:/u/niuqin/apache-tomcat-7.0.35/bin/tomcat-juli.jar
Picked up _JAVA_OPTIONS: -Xms512m -Xmx512m
[niuqin@silo logs]$ ps -ef | grep niuqin
root     15983  6712  0 11:35 ?        00:00:00 sshd: niuqin [priv]
niuqin   15989 15983  0 11:35 ?        00:00:00 sshd: niuqin@pts/35
niuqin   15990 15989  0 11:35 pts/35   00:00:00 -bash
niuqin   19133 15990  0 12:05 pts/35   00:00:00 ps -ef
niuqin   19134 15990  0 12:05 pts/35   00:00:00 grep niuqin
[niuqin@silo logs]$ /u/niuqin/apache-tomcat-7.0.35/bin/startup.sh
Using CATALINA_BASE:   /u/niuqin/apache-tomcat-7.0.35
Using CATALINA_HOME:   /u/niuqin/apache-tomcat-7.0.35
Using CATALINA_TMPDIR: /u/niuqin/apache-tomcat-7.0.35/temp
Using JRE_HOME:        /usr/lib/jvm/jre-1.7.0-openjdk.x86_64
Using CLASSPATH:       /u/niuqin/apache-tomcat-7.0.35/bin/bootstrap.jar:/u/niuqin/apache-tomcat-7.0.35/bin/tomcat-juli.jar
[niuqin@silo logs]$ pwd
/u/niuqin/apache-tomcat-7.0.35/logs
[niuqin@silo logs]$ ls -l
total 12
-rw------- 1 niuqin students 1590 Jul 15 12:05 catalina.2015-07-15.log
-rw------- 1 niuqin students 1633 Jul 15 12:05 catalina.out
-rw------- 1 niuqin students    0 Jul 15 12:05 host-manager.2015-07-15.log
-rw------- 1 niuqin students  450 Jul 15 12:05 localhost.2015-07-15.log
-rw------- 1 niuqin students    0 Jul 15 12:05 manager.2015-07-15.log
[niuqin@silo logs]$ ls -l
total 12
-rw------- 1 niuqin students 1590 Jul 15 12:05 catalina.2015-07-15.log
-rw------- 1 niuqin students 1633 Jul 15 12:05 catalina.out
-rw------- 1 niuqin students    0 Jul 15 12:05 host-manager.2015-07-15.log
-rw------- 1 niuqin students  450 Jul 15 12:05 localhost.2015-07-15.log
-rw------- 1 niuqin students    0 Jul 15 12:05 manager.2015-07-15.log
[niuqin@silo logs]$ ls -l
total 12
-rw------- 1 niuqin students 1590 Jul 15 12:05 catalina.2015-07-15.log
-rw------- 1 niuqin students 1633 Jul 15 12:05 catalina.out
-rw------- 1 niuqin students    0 Jul 15 12:05 host-manager.2015-07-15.log
-rw------- 1 niuqin students  450 Jul 15 12:05 localhost.2015-07-15.log
-rw------- 1 niuqin students    0 Jul 15 12:05 manager.2015-07-15.log
[niuqin@silo logs]$ more *
::::::::::::::
catalina.2015-07-15.log
::::::::::::::
Jul 15, 2015 12:05:19 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-bio-13755"]
Jul 15, 2015 12:05:19 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 690 ms
Jul 15, 2015 12:05:19 PM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
Jul 15, 2015 12:05:19 PM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.35
Jul 15, 2015 12:05:19 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory /nfs/nfs4/home/niuqin/apache-tomcat-7.0.35/webap
ps/ROOT
Jul 15, 2015 12:05:19 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory /nfs/nfs4/home/niuqin/apache-tomcat-7.0.35/webap
ps/host-manager
Jul 15, 2015 12:05:19 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory /nfs/nfs4/home/niuqin/apache-tomcat-7.0.35/webap
ps/manager
Jul 15, 2015 12:05:20 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory /nfs/nfs4/home/niuqin/apache-tomcat-7.0.35/webap
ps/docs
Jul 15, 2015 12:05:20 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory /nfs/nfs4/home/niuqin/apache-tomcat-7.0.35/webap
ps/examples
Jul 15, 2015 12:05:20 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-13755"]
Jul 15, 2015 12:05:20 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 992 ms
::::::::::::::
catalina.out
::::::::::::::
Picked up _JAVA_OPTIONS: -Xms512m -Xmx512m
Jul 15, 2015 12:05:19 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-bio-13755"]
Jul 15, 2015 12:05:19 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 690 ms
Jul 15, 2015 12:05:19 PM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
Jul 15, 2015 12:05:19 PM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.35
Jul 15, 2015 12:05:19 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory /nfs/nfs4/home/niuqin/apache-tomcat-7.0.35/webap
ps/ROOT
Jul 15, 2015 12:05:19 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory /nfs/nfs4/home/niuqin/apache-tomcat-7.0.35/webap
ps/host-manager
Jul 15, 2015 12:05:19 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory /nfs/nfs4/home/niuqin/apache-tomcat-7.0.35/webap
ps/manager
Jul 15, 2015 12:05:20 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory /nfs/nfs4/home/niuqin/apache-tomcat-7.0.35/webap
ps/docs
Jul 15, 2015 12:05:20 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory /nfs/nfs4/home/niuqin/apache-tomcat-7.0.35/webap
ps/examples
Jul 15, 2015 12:05:20 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-13755"]
Jul 15, 2015 12:05:20 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 992 ms
::::::::::::::
host-manager.2015-07-15.log
::::::::::::::
::::::::::::::
localhost.2015-07-15.log
::::::::::::::
Jul 15, 2015 12:05:20 PM org.apache.catalina.core.ApplicationContext log
INFO: ContextListener: contextInitialized()
Jul 15, 2015 12:05:20 PM org.apache.catalina.core.ApplicationContext log
INFO: SessionListener: contextInitialized()
Jul 15, 2015 12:05:20 PM org.apache.catalina.core.ApplicationContext log
INFO: ContextListener: attributeAdded('org.apache.jasper.compiler.TldLocationsCache', 'org
.apache.jasper.compiler.TldLocationsCache@7321803a')
::::::::::::::
manager.2015-07-15.log
::::::::::::::
[niuqin@silo logs]$

So it's time to go online and check it from the web.

Here's how I create the squash context/application. 





   mkdir $CATALINA_HOME/webapps/squash 

   mkdir $CATALINA_HOME/webapps/squash/WEB-INF 

   mkdir $CATALINA_HOME/webapps/squash/WEB-INF/classes 

   mkdir $CATALINA_HOME/webapps/squash/WEB-INF/lib 

   pico -w $CATALINA_HOME/webapps/squash/index.html 

Here's the content of the file please: 

<html>
  <head>
    <title>
      My form on Wed 07/15
    </title>
  </head>
  <body>

    <form action=/squash/servlet/Radish method=GET>

      <table border>
        <tr>
          <td> Name </td> <td> <input type=text name=who> </td>
        </tr>
        <tr>
          <td> Age </td> <td> <input type=text name=age> </td>
        </tr>
        <tr>
          <td colspan=2> Press <input type=submit value=Submit> to send data to servlet</td>
        </tr>
      </table>
    </form>
  </body>
</html>

   pico -w $CATALINA_HOME/webapps/squash/WEB-INF/web.xml 

Here's what the contents of the file should be please:

<?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>radijs</servlet-name>
    <servlet-class>One</servlet-class>
  </servlet>

  <servlet-mapping>
    <servlet-name>radijs</servlet-name>
    <url-pattern>/servlet/Radish</url-pattern>
  </servlet-mapping>

</web-app>

   pico -w $CATALINA_HOME/webapps/squash/WEB-INF/classes/One.java 

The content is

import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class One extends HttpServlet {
  public void doGet(HttpServletRequest request,
                    HttpServletResponse response) throws IOException, ServletException {
    String name = request.getParameter("who");
    String age = request.getParameter("age");

    response.setContentType("text/html");
    PrintWriter out = response.getWriter();
    out.println("Well, " + name + " you will be " + (age + 1) + " next year.");
  }
}

   cd $CATALINA_HOME/webapps/squash/WEB-INF/classes 
   javac One.java 

Now later on you replace age with Integer.parseInt(age) and recompile. 

You also go in as manager-gui and reload the context and the new servlet kicks in. 

--   

Mark Logan Daniel Nathan Jared James Trevor

Qin Judy Aleksa Adam Gabriela Hallie Brennan Jacquelyn 

Nick Yiming Jingzhe Paul Morgan Alex Ong William 

Jon Grant MAR Mohan Jack Walter Lauren