Developing web apps on your computer


You can set up your own computer to support your web app development at home. This will allow you to do most of your development and testing locally. You will still need to make your web apps available to the instructors.

Apache Tomcat is the most common container for web applications, including Java-J2SE technologies. It is open-source and free and widely used by developers and industry.

  1. Download and install the latest Java development kit. You might have a Java compiler on your computer, but it might be an older version and it might not include the servlet libraries. This is a good time to upgrade
    Download the Java development kit from http://java.sun.com/
  2. Download and install Apache Tomcat. This will allow you to deploy and run all the Java web technologies, starting with servlets and JSPs.
    Download Tomcat from https://tomcat.apache.org/. Remember where Tomcat is installed. In particular, you will need to find the webapps directory later.
  3. You may need to restart your computer.
  4. After setting up Tomcat, the web applications included with the installation will be available from http://localhost:8080/.

Deploying servlets

  1. Go to the webapps directory under your Tomcat installation. The location depends on your OS and the Tomcat version.
  2. You might need to create a project directory under webapps. Assume you choose the project name swe432. You will need the following directories:
    Directory Contains
    \swe432 This is the root directory of the web application. All JSP and XHTML files are stored here.
    \swe432\WEB-INF\classes This directory is where servlet and utility classes are located.
    \swe432\WEB-INF This directory contains all resources related to the application that are not in the document root of the application. This is where your web application deployment descriptor is located. Note that the WEB-INF directory is not part of the public document. No files contained in this directory can be served directly to a client.
    \swe432\WEB-INF\lib This directory contains Java Archive files that the web application depends upon. For example, this is where you would place a JAR file that contained a JDBC driver.
  3. After compiling Java classes, copy the .class files to the classes directory. After copying a new .class file, you may need to restart Tomcat. (You can configure this later.)
  4. Run your servlet by entering this URL into your browser: http://localhost:8080/ProjectRoot/ServletName/
    For example, http://localhost:8080/swe432/hello
  5. Shutdown tomcat with the shutdown command.