Why was my question about compiling servlets moved from the servlets forum to the Beginning Java forum?
Servlets are nothing more than Java classes with some dependencies. They are dependent on libraries in the javax.servlet and javax.servlet.http packages. All of these libraries are present in j2ee.jar which can be downloaded from http://java.sun.com. Some servlet containers ship with a sub-set of the J2EE libraries; making it unnecessary to download j2ee.jar separately. For instance, if you’re using the Tomcat Application server the libraries can be found in TOMCAT_INSTALL_DIRECTORY/common/lib/servlet-api.jar (in older versions, it’s called servlet.jar), or TOMCAT_INSTALL_DIRECTORY/lib/servlet-api.jar for versions above 6.0. Take a look to see which one you have. Once you have located the jar file that needs to be added to your classpath, proceed to HowToSetTheClasspath to learn how to set up your classpath in order to compile your Java classes.