Servlet Configuration  «Prev  Next»

Lesson 3Configuring your system to use the JSDK
ObjectiveConfigure your system to use the JSDK.

Configuring your System to use the JSDK

The (JSDK) Java Servlet Development Kit was first release by Sun in 1998. The Java Web Server
After you have downloaded and installed the JSDK, you might be tempted to code a simple servlet and try to compile it.
If you did, you would get errors from the Java compiler, does not know where to find the
javax.servlet.http.HttpServlet class that your servlet extends. Although you have downloaded it, the compiler does not know that.
To tell the compiler how to find the class, you need to set the CLASSPATH environment variable.
Here is how to do it on a Windows computer.
Start an MS-DOS prompt in the usual way. Change directories to the folder where you plan to create your servlets. Type this command:
set CLASSPATH=%CLASSPATH%;c:\jsdk2.1\servlet.jar

On a UNIX system, use the same command but substitute your current classpath value according to the shell you are using.
The classpath lists the folders or directories that the Java compiler will search to find the packages you import, separated by semicolons.
This command takes the existing classpath, and adds the JSDK classes to it. If you installed the JSDK to a different folder or subdirectory, adjust this command accordingly.


Create script file

If you tire quickly of typing commands like this, you might want to create a small batch or script file that will set the classpath for you. I called mine cp.bat and keep it in the same directory as my servlet code.
In the next lesson a text editor for your Java work will be chosen.

Configuring System - Exercise

Click on the link below to learn about configuring your system.
Configuring System - Exercise
So far, we have portrayed servlets as an alternative to other dynamic web content technologies, but we have not really explained why we think you should use them. What makes servlets a viable choice for web development?
We believe that servlets offer a number of advantages over other approaches, including: portability, power, efficiency, endurance, safety, elegance, integration, extensibility, and flexibility.