Jsp&Servelet study notes (3)
Author:Eve Cole
Update Time:2009-07-02 17:15:06
1.3 Compile a servlet
If you have written a servlet and now want to compile it into a class file, what should you do?
First, you need to confirm whether servlet-api.jar is configured under your classpath. Then you can compile it with the javac command just like compiling other java source files; (note: a servlet must be packaged and placed under the classpath)
· Tomcat 5 supports servlet API 2.4; the path to the jar file:
<Tomcat-5-installation-directory>/common/lib/servlet-api.jar.
· Compiling a servltet requires importing the javax.servlet javax.servlet.http package
For a BEA WebLogic 7.0 servlet, you may use javax sub-packages such as javax.ejb, javax.mail, javax.sql. These packages will be under <WebLogic-installation-directory>/weblogic700/server/lib/weblogic.jar. For example :javac -classpath K:tomcat5jakarta-tomcat-5distcommonlibservlet-api.jar -d ./build ./src/FirstServlet.java