GETTING STARTED WITH JAVA SERVLETS |
This document summarizes the steps necessary for preparing, compiling and running your own Java servlets. The server and servlet engine A web server is set up for CMPT 310 in 2000-3. It is Apache 1.3.11 and runs on the CSIL Sun server gemini.csil.sfu.ca:8080, port 8080. It is capable of running servlets. The servlet engine is Apache JServ 1.1.2. Documentation is available at http://java.apache.org/ Your servlets zone / directory and URL Each user has a zone for servlets. This is a directory under which you can place your servlets. It is accessible on gemini.csil.sfu.ca, at
Initially this directory is setup for you to contain a servlet example:
a makefile in that directory shows the use of javac with the jsdk in the classpath. Your servlets properties Each user owns a file in their web area on gemini which belongs to the user and sets the servlet properties.
this file must be readable by the user nobody. Java Servlet Development Kit 2.0 The jdsk2.0 is located on gemini.csil.sfu.ca, in the /WWW/jsdk2.0 directory. If you want to you use it you need to logon on gemini.csil.sfu.ca. If you want to compile your servlet applications on gemini, use the CLASSPATH /WWW/jsdk2.0/lib/jsdk.jar for using with javac. A typical steps to compile and running your servlet is as follows: 1. You can create a new Java Servlet document which is just a Java Class implement a special interface, using the methods we learnt from the GETTING STARTED WITH JAVA tutorial. The directory to hold all the servlets for you is /WWW/users/youruserid/servlets/ Below is an example program: Hello471.java
import java.io.*; import javax.servlet.*; import javax.servlet.http.*;
public class Hello470 extends HttpServlet { /** * Handle the GET and HEAD methods by building a simple web page.
}
2. Log on to gemini.csil.sfu.ca: (in your case, replace tlie by your own Unix ID)
Launch your browser and go to URL:
The servlet will create a dynamic HTML page for you, shows on the screen as:
Congradulations! Your have successfully compiled and run your Java Servlet on the web server! |