Download eclipse
Http://www.eclipse.org/
Download Tomcat Eclipse plug-in
Http://www.eclipsetotale.com/tomcatPlugin.html
Decompress the tomcatpluginv321.zip content to the eclipse plugins directory, and then restart eclipse
Window-> perferences-> familiar with tomcat version directory configuration, remember to press apply
Download Tomcat
Http://tomcat.apache.org/
Test servlet example
File-> New Project (Java Tomcat Project)
Enter test next and then enter test and finish.
Right-click the test project, new class package name test, and class name Test
Javax. servlet. http. httpservlet
Open test. Java, right-click the content of the test. Java file source-> override/implement methods
Select doget dopost
Remove the base class and call Super. doget (req, resp );
Input
Printwriter out = new printwriter (resp. getoutputstream (); <br/> out. println ("<HTML>"); <br/> out. println ("<pead> <title> servlet1 </title> </pead>"); <br/> out. println ("<body> Hello world! "); <Br/> out. println (" </body> </ptml> "); <br/> out. Close (); </P> <p>
Right-click printwriter, source-> organize Import
Right-click the test project and choose Properties> JAVA build path> order and export.
Create the deployment file web. xml of the project and put it in the test/Web-INF directory.
<? XML version = "1.0" encoding = "ISO-8859-1"?> <Br/> <web-app> </P> <p> <servlet> <br/> <servlet-Name> test </servlet-Name> <br/> <servlet-class> test. test </servlet-class> <br/> </servlet> </P> <p> <servlet-mapping> <br/> <servlet-Name> test </Servlet -Name> <br/> <URL-pattern>/test/* </url-pattern> <br/> </servlet-mapping> <br/> <session-config> <br/> <session-Timeout> 30 </session-Timeout> <br/> </session-config> <br/> </Web-app> </P> <p>
Start Tomcat
Access http: // localhost: 8080/test