Setup a Development Environment for CS320

1. Software Installation

Download and install the latest JDK from Sun Microsystems - we only need the JDK, not Java EE or NetBeans.

Download the latest Tomcat binary release from the Apache Project. Note that there are several packages available for download. You should download the ZIP file under the "Core" distribution. After downloading the file, unzip it to a local directory, e.g. c:\apache-tomcat-6.0.18.

Download JSP Standard Tag Library (JSTL) from the Apache Jarkata Project. Extract two jar files, jstl.jar and standard.jar, from the zip file you downloaded, and place them under the lib folder under the Tomcat folder, e.g. c:\apache-tomcat-6.0.18\lib.

Download the MySQL JDBC driver called "MySQL Connector/J" from Extract the jar file mysql-connector-java-#.#.#-bin.jar (#.#.# is the version number, e.g. 5.1.6) from the zip file you downloaded, and place it under the lib folder under the Tomcat folder.

Download Eclipse from There are several packages to choose from, and we need the one that is called "Eclipse IDE for Java EE Developers". After downloading the file, unzip it to a local directory, e.g. c:\eclipse.

Note that instead of downloading all the software from the Internet, you may also get them from the MSDNAA software computer in the CS department office. The files are under the "CS320 Fall 2008 Software" folder on the Windows Desktop. The total size of the files is about 300MB. You need to bring with you a flash drive or a writable CD.

2. Using Eclipse

In this section we will create a sample web application using Eclipse. The application consists of a servlet called HelloServlet and a JSP page HelloJSTL.jsp. A screen capture video is available to demonstrate this process.

First, start up Eclipse by double-click on eclipse.exe under the Eclipse folder, e.g. c:\eclipse\eclipse.exe. If you are using Eclipse for the first time, you will be asked to choose a folder to be Eclipse's workspace. Eclipse will store all your projects in that folder.

After Eclipse is started, create a Dynamic Web Project (File -> New -> Dynamic Web Project). You need to specify the project name and a target runtime. We'll use hello as the project name. The type of the target runtime is Apache Tomcat 6.0, and the installation directory is your Tomcat folder, e.g. c:\apache-tomcat-6.0.18.

Create a new servlet (Right click on the project name -> New -> Servlet). Enter cs320.sample as the package name and HelloServlet as the class name then click Finish. Edit so the doGet() method looks like the following:

protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    response.getWriter().print("Hello Servlet");

Create a new JSP page (Right click on the project name -> New -> JSP). Enter HelloJSTL.jsp as the file name. Edit HelloJSTL.jsp so it looks like the following:

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
<%@ taglib prefix="c" uri="" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "">
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
<c:out value="Hello JSTL" />

Run the application (Right click on the project name -> Run As -> Run on Server). Select Tomcat v6.0 Server as the server type then click Finish. Enter the URL http://localhost:8080/hello/HelloServlet in a browser and you should see "Hello Servlet" output by the servlet, and enter the URL http://localhost:8080/hello/HelloJSTL.jsp and you should see "Hello JSTL" displayed by the JSP page.

3. Deployment on CS3 Server

Each student in the class is assigned an account on the CS3 server. The account name is in the form of cs320stu##, e.g. cs320stu31.

To deploy your application onto the CS3 server, you simply need to transfer the following files from your Eclipse project to their corresponding folders under your CS3 account:

Note that directory structure must be preserved during file transfer, e.g. build/classes/cs320/sample/HelloServlet.class should be transfered to www/WEB-INF/classes/cs320/sample/HelloServlet.class under your account on the CS3 server.

After your application is deployed on the CS3 server, you may access it using the following URL:<username>/<servlet_or_jsp_name>

where <username> is your account name on the server, e.g. cs320stu31. Note that the name of a servlet depends the <servlet-mapping> settings in your web.xml file, i.e. it's not necessarily the name of the servlet class.

A screen capture video is available to demonstrate the deployment process.