Contact Us

Breadcrumb Navigation

CS Lab Deploy Servlet/JSP Programs to the Tomcat Server

Quick Reference Guide

The Department of Computer Science lab computers have been set up to deploy servlets and JSP to our tomcat server. This documentation will provide instructions on how to utilize our lab environment for deploying servlets and JSP to our tomcat server.

Please note, tomcat 8 (our tomcat deployment server) only supports code compiled with version java 1.7.+. We recommend end-users download the template to pc00.cs.siu.edu or pc01.cs.siu.edu over ssh and follow the deployment guide to avoid version mismatch errors occurring when you attempt to deploy your template.

1. Please use pc00.cs.siu.edu or pc01.cs.siu.edu over ssh. Windows users can utilize putty to establish an ssh connection.

3. Unzip the sample deployment archive to any location on your computer. (You will need to remember this location when you deploy with ant later.)*

$ unzip sample-deploy-servlet.zip

Contents of sample-deploy-servlet:

4. Inside the directory "sample-deploy-servlet" or "sample-deploy-jsp" rename "your_login_ID" to your name ie: jsmith for John Smith

5. Copy any JSP files you want submitted into "sample-deploy\your_login_ID"

6. Copy all the servlet ".java" files to sample-deploy\your_login_ID\WEB-INF\classes" directory

Please note when you later execute the ant build command .java files will be compiled to .class servlets with : javac *.java inside of this directory.

7. The sample deployment comes with a valid sample web.xml, which should work for testing your deployment environment.

You'll need to modify the "web.xml" file for different servlets classes. The file is located at sample-deploy\your_login_ID\WEB-INF. You'll need to change the name of servlet-class to reflect your java class in the sample code below:

8. Copy the newly created "web.xml" file to the "sample-deploy\your_login_ID\WEB-INF" directory or leave the existing one in place for testing compilation of your code into a JAR file.

9. After completing all the steps above, you will have the following directory and file structure :
"sample-deploy\"
"sample-deploy\your_login_ID\"
"sample-deploy\your_login_ID\all_my_ jsp_files"
"sample-deploy\build.xml"
"sample-deploy\your_login_ID\WEB-INF\"
"sample-deploy\your_login_ID\WEB-INF\web.xml"
"sample-deploy\your_login_ID\WEB-INF\classes\"
"sample-deploy\your_login_ID\WEB-INF\classes\all_my_servlet_class_files"
"sample-deploy\your_login_ID\WEB-INF\lib\"
"sample-deploy\your_login_ID\WEB-INF\lib\all_jar_files_and_jdbc"

10. Open a dos command prompt or terminal under linux and cd to your sample-deploy-servlet or sample-deploy-jsp directory.

11. To compile your servlet/jsp into a .war file, run command:

ant -buildfile build.xml -Dwebapp=your_login_ID compile

When it is finished, it will tell you whether it is successful or not.

12. To deploy your servlet to the departmental Tomcat server (http://web.cs.siu.edu:8080), run command:

ant -buildfile build.xml -Dwebapp=your_login_ID deploy

You will see it is running the deployment. When it is finished, it will tell you whether it is successful or not.

13. Run your deployed program in your favorite web browser by typing the following url:

14. Please note, if you compiled and deployed the sample project and plan to modify the same sample deployment project, then it is recommended that you delete the sample project files that we were created. This will need to be done prior to compiling and deploying the new project to the server.

The above example will archive your HelloWorld.jsp file located at
"sample-deploy\your_login_ID" into the .WAR file when compiled.

The .WAR file is used to deploy your application to the Tomcat server.
The <servlet-class>org.apache.jsp.HellWorld_jsp</servlet-class> or more
simply <servlet-class>HelloWorld</servlet-class> in the web.xml
file reflects the directory structure to your .jsp file inside your .WAR archive.

This can be examined after running the ant compile command by exploring
the directory created at "sample-deploy-jsp\your_login_ID\build"

When developing your own application it is possible the directory structure
will change and require that you modify your web.xml file to accommodate
this directory structure appropriately.