banner

Deploy Servlet/JSP Programs to the Tomcat Server

  • 1. Log on to a Windows computer in the department lab using your own windows account
  • 2. Create a new folder on your M: drive, which is your home directory under Windows. For example, "M:\tomcat_deployment"
  • 3. Create a folder under the "M:\tomcat_deplyment" folder, using your login ID as the folder name, e.g. "ychen" or "siucs-07"
  • 4. Create a folder "WEB-INF" under the "M:\tomcat_deployment\your_login_ID" folder (replacing the "your_login_ID" part with your real login ID, such as "ychen" or "siucs-07")
  • 5. Create a folder "classes" under the "M:\tomcat_deployment\your_login_ID\WEB-INF" folder
  • 6. Copy the jsp files you want to submit to the "M:\tomcat_deployment\your_login_ID" folder

    Copy all the servlet class files to M:\tomcat_deployment\your_login_ID\WEB-INF\classes" folder
    Download and copy the build.xml (for Lindegren 18 Lab) (for Faner 2102 Lab or TA offices) file to the "M:\tomcat_deployment" folder.
  • 7. You also need to write a "web.xml" file for your servelet. A sample file is available here (web.xml). You just need change the name of servlet in the sample, "test", to the name of your own servlet. Or, you can create a mimimal web.xml file with the following contents (remember to change the name of servlet to yours):

    <web-app>
          <servlet>
                <servlet-name>test</servlet-name>
                <servlet-class>test</servlet-class>
          </servlet>
          <servlet-mapping>
                <servlet-name>test</servlet-name>
                <url-pattern>/test</url-pattern>
          </servlet-mapping>
    </web-app>

  • 8. Then copy the newly created "web.xml" file to the "M:\tomcat_deployment\your_login_ID\WEB-INF" folder

  • 9. After completion of all the steps above, you will have the following directory and file structure on your drive M:
    "M:\tomcat_deployment\"
    "M:\tomcat_deployment\your_login_ID\"
    "M:\tomcat_deployment\your_login_ID\all_my_ jsp_files"
    "M:\tomcat_deployment\build.xml"
    "M:\tomcat_deployment\your_login_ID\WEB-INF\"
    "M:\tomcat_deployment\your_login_ID\WEB-INF\web.xml"
    "M:\tomcat_deployment\your_login_ID\WEB-INF\classes\"
    "M:\tomcat_deployment\your_login_ID\WEB-INF\classes\all_my_servelet_class_files"
  • 10. Then run command "ant -buildfile build.xml -Dwebapp=your_login_ID" to deploy your servlet to the departmental Tomcat server (http://lab.cs.siu.edu:8080). You will see it is running the deployment. When it is finished, it will tell you whether it is successful or not.
  • 11. Then, you can run your deployed progam by typing "http://lab.cs.siu.edu:8080/your_login_ID/jspfilename_or_servlet_name. For example:

    Servlet: http://lab.cs.siu.edu:8080/ychen/test
    JSP: http://lab.cs.siu.edu:8080/ychen/hello.jsp