Tomcat Version: 4.1.31 / 5.0.28 Setup Virtual Path: Path: Defined at the address Attached virtual names in the column, for example, after configuring Http://127.0.0.1/example, you can automatically access you E: / Project / Java / lower Project (DocBase is the actual path of the project), he will Automatically look for files named Index, extension .jsp / .htm / .html, etc. is the homepage. If you want to change the Tomcat default directory, you will change the value of the appbase to your actual path.! - Debug = 0 "AppBase =" WebApps "UnpackWars =" true "autodeploy =" true "> This can be accessed directly via http: // localhost or http://127.0.0.1. Setting Server port: change the value of the port to the port you want, 80 is the default The HTTP service port, such as changed to other ports, when access is accessed, add the specified port EXAMPLE: 80 port: http://127.0.0.1/example8080 port: http://127.0.0.1:8080/ Example Sets Web.xml under Project: Many people directly paste the web-infml of the web-infmails under Tomcat, which can also start, but will report an error, pay attention to Web.xml: in Tomcat. Org.apache.jasper.servlet.jspservlet servlet-class> Solution is to make it clean with Web.xml under your web-infers: XML Version = "1.0" encoding = "UTF-8"? > myProject display-name> web-app> This is OK.
To set up servlet under different versions of Tomcat: Copy your own servlet.class to your own project's Web-INF / CLASSES, then in Tomcat's Web.xml: Invoker servlet- Name> org.apache.catalina.servlets.invokerservlet servlet-class> debug param-name> 0 param-value > Init-param> 2 load-on-startup> servlet> If this paragraph is commented, you can get it ------------ ---------------------------------------- Invoker servlet-name> / servlet / * url-pattern> servlet-maping> This Tomcat 4.1.31 previous version requires yourself to join, 4.1.31 and 5 series Tomcat as long as The annotation removed from this paragraph. In addition, after setting the Web.xml of Tomcat, you will need to return to your own project path to set Web.xml, the content is as follows: firstservlet servlet-name> HelloWorldServlet servlet-class> servlet> web-app> then entered in the address: http://127.0.0.1/example/servlet/firstServlet This you can visit your own servlet HelloWorldServlet .java ------------------------- Import javax.servlet. *; import javax.servlet.http. *; public class helloworldServlet Extends httpservlet { public void service (HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {PrintWriter pw = response.getWriter (); pw.println ( ""); pw.println ( ""); pw.println ( " head>"); PW.Println (""); PW.Println (" Hello! H1>); PW.Println (" Body> "); PW. Println (" html>");}} * If reproduced, please note http://blog.9cbs.net/darkula