Build an eclipse servlet Environment

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.