2 Minutes To Code (β Version)

Java Servlets - 2 minute tutorial

How to compile a servelt

Let's see how to compile a servlet. To compile it you need servlet-api.jar that can be obtained from the library folder of any web-server that implements servlet specification. In tomcat, servlet-api.jar is present in the $TOMCAT_HOME/lib or $TOMCAT/common/lib folder.

Just add servlet-api.jar in teh classpath and run the javac command as shown in the image below where FirstServlet.java is the servlet class name.