Operating environment: JDK 5.0 Tomcat 5.5.4
JDK installation path: d: /java/jdk1.5.0_01tomcat installation path: D: / Tomcat 5.5
Set an environment variable (Control Panel -> System -> Advanced): Java_Home = D: /JAVA/JDK1.5.0_01path=%java_Home%/binclasspath = .; D: /java/jdk1.5.0_01/lib/dt.jar; D: /java/jdk1.5.0_01/lib/tools.jar; D: / Tomcat 5.5 / Common / lib / servlet-api.jar
Where D: / Tomcat 5.5 / Common / lib / servlet-api.jar is implemented for Tomcat's servlet API, must be added, it is better to compile servlet
Tomcat5.5 Virtual Directory Settings: D: / Tomcat 5.5 / Conf / Catalina / LocalHost New Test.xml content is as follows:
D: / WWW path will be the root of our test website, access to this virtual directory with http: // localhost: 8080 / test D: / www, copying a directory web-inf, there is a web.xml setting file (you can refer D: / Tomcat 5.5 / WebApps / root / web-inf / web.xml), classes directory and lib directory
An example // file name Welcome.javaImport java.io. *; import javax.servlet. *; import javax.servlet.http. *;
Public class welcome extends httpservlet {public welcome () {}
public void doGet (HttpServletRequest Req, HttpServletResponse Res) throws ServletException, IOException {Res.setContentType ( "text / html"); PrintWriter out = Res.getWriter (); out.println ( "
Compile Javac Welcome.java, put the compiled file Welcome.class to the directory D: / www / web -inf / classes and then modify D: / www/web-inf/web.xml, add the following settings