Installed Tomcat. We have $JAVA_HOME, $CATALINA_HOME, $CLASSPATH $CATALINA_HOME/conf/server.xml is the equivalent of httpd.conf $CATALINA_HOME/webapps/ROOT/index.jsp gave us trouble $CATALINA_HOME/webapps/ROOT/index.html wasn't there We will spend most of our time in $CATALINA_HOME/webapps/ because that's where the contexts are. Each context is a folder that has a name and a structure. The name is up to you, the structure isn't. A context has a WEB-INF folder that has two other folders inside: lib and classes. We said classes is where the servlets will be placed. If you create a folder you can access it over the web. We access them through the manager if not directly. The manager is an interface to the heart of the server (Tomcat) in the sense that you can manage all that's happening in it through this interface. So we start by creating a new context. Don't forget to add an index.html file to your context. import java.util.*; class One { public static void main(String[] args) { Date d; d = new Date(); System.out.println(d); } } -bash-3.2$ pwd /u/dgerman/apache-tomcat-5.5.17/webapps/tuesday -bash-3.2$ ls -l total 16 -rw-r--r-- 1 dgerman faculty 41 Apr 7 13:43 index.jsp drwxr-xr-x 4 dgerman faculty 4096 Apr 7 13:24 WEB-INF -bash-3.2$ cat index.jsp Today's date <%=new java.util.Date()%> -bash-3.2$ Here's a new example: <% int x; x = 3 + 4; %> <%=x%> So we then developed this: <% String x = request.getParameter("x"); if (x == null) { x = "0"; } else { x = (Integer.parseInt(x) + 1) + ""; } %>
Comments from Mason, Sujit and Andrey.