How to deploy a project to Tomcat in MyEclipse

Source: Internet
Author: User

If Tomcat is not configured in the system, refer to "How to configure Tomcat environment variables under Windows".

1. Create a new Web project item. As follows:

The effect is as follows:

2. Write a Java class that implements the Servlet interface or inherits HttpServlet

1 Package Com.cnblogs.daliu_it.web;2 3 import java.io.IOException;4 import Java.io.PrintWriter;5 import javax.servlet.ServletException;6 import Javax.servlet.http.HttpServlet;7 import javax.servlet.http.HttpServletRequest;8 import Javax.servlet.http.HttpServletResponse;9 Ten  Public classHelloWorld extends HttpServlet { One     protected voidService (HttpServletRequest req, HttpServletResponse resp) A throws Servletexception, IOException { -Resp.setcontenttype ("text/html"); -PrintWriter out=Resp.getwriter (); the          out. Write (""); -          out. Close (); -     } -}
View Code


3. Modify the Web. xml file.

1<?xml version="1.0"encoding="UTF-8"?>2<web-app version="2.5"xmlns="Http://java.sun.com/xml/ns/javaee"3Xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"4xsi:schemalocation="Http://java.sun.com/xml/ns/javaee5http//java.sun.com/xml/ns/javaee/web-app_2_5.xsd ">6<display-name></display-name>7<servlet>8<servlet-name>HelloWorld</servlet-name>9<servlet-class>com.cnblogs.daliu_it.web.helloworld</servlet-class>Ten</servlet> One  A<servlet-mapping> -<servlet-name>HelloWorld</servlet-name> -<url-pattern>/HelloWorld</url-pattern> the</servlet-mapping> -<welcome-file-list> -<welcome-file>index.jsp</welcome-file> -</welcome-file-list> +</web-app>
View Code


4. Deploying to Tomcat

(1) Configuring the server

(2) Select the extracted directory for Tomcat 7.0.

Click Apply.

Click OK.

5. Deploy to Tomcat

Click Finish. Then OK.


6. Start Tomcat,

7. Access the servlet.

Http://localhost:8080/firstweb/HelloWorld


Original Daliu_it
Blog Source: http://www.cnblogs.com/liuhongfeng/p/4178424.html

How to deploy a project to Tomcat in MyEclipse

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.