The servlets run by a program called TOMCAT. TOMCAT runs on birch.wellesley.edu and uses the port 8080. Servlets are orgainzed into web applications. A web application may include Java classes, Java .jar files, images, and so on. To access a servlet, one needs to specify the application to which the servlet belongs. For instance, if you type
in your browser, this you are accessing a servlet
MySession1in the web application
When a request for a servlet is made, TOMCAT checks if the servlet with this class is already running. If the servlet is already running and its class has not changed since the last access, then the request is forwarded to the servlet. If its class has changed or the servlet is not running, then its class is started.
images, which contains .gif and .jpg files used by the servlets. See the "ice cream shop with graphics" example here to see how to use an image in a servlet.
WEB-INF, which contains:
classesfor all java classes used in the application. They include all the servlet classes and other Java classes used by the servlets. For instance, the web application
examplescontains, among others, files IceCream1.class and KillSession.class (the two servlets in the ice cream shop application), and also the file Order.class (the java class used by these servlets). Even though you may put .java files in this directory, they don't have to be there. You will copy your servlet classes into this directory
libfor all .jar files used in the application. Your application has mckoidb.jar file in its
libdirectory. Once a .jar file is placed in this directory, all servlets can automatically access it.
web.xml: the file that describes your web application. In this assignment we don't need to do anything with this file, but we might need to modify it in the future.
servletsin a web application directory has nothing to do with the classes of servlets. You will not need to access it.
A web application with your project login name has been created for
each project group. The directory is
birch.wellesley.edu. Instead of myproj you will use your project login
To compile the servlet, type
If it uses other classes, you can compile them all together as
or separately. Files MyGreatServlet.class and MyHelperClass.class will be created if the compilation is successful.
javacee MyGreatServlet.java MyHelperClass.java
Servlets are supported in Java 2 Enterprise Edition (J2EE). So far you
have been working with Java 2 Standard Edition.
javacee is a variation of the Java compiler
javac which includes J2EE libraries.
Note that the abbreviation
javacee exists only on puma
(including puma hosts, s.a. lion, tiger, etc.) and on birch, but not
on other Wellesley machines and not outside of Wellesley.
To "run" your servlet, you need to copy its class(es) to the directory
on birch. Actually, your puma account is accessible on birch with the
same password as on puma. Files are shared between puma and birch, so
all your file changes on puma will immediately take affect on birch,
To copy the class files, you need to:
will connect you to birch with your current login name. You may get the following warning:
Type yes (all three letters).
The authenticity of host 'birch (188.8.131.52)' can't be established. RSA key fingerprint is ... Are you sure you want to continue connecting (yes/no)?
Instead of MyGreatServlet.class use the name of your servlet, and instead of myproj use the login name of your project.
cp MyGreatServlet.class /etc/tomcat3/conf/jakarta-tomcat-3.3a/webapps/myproj/WEB-INF/classes/.
in your browser (you may omit .wellesley.edu) to test your servlet. Copy other classes used by the servlet if they have been recompiled.