Eclipse + Tomcat integration development servlet

zhaozj2021-02-16  44

Eclipse is an integrated development environment of Open Source. It has been strongly supported by IBM, and Tomcat is more familiar, it is a JSP / Servlet container for Apache, which will tell how integration:

ready:

1. Tomcat4.0

2. JDK1.4

3. Eclipse2.0

4. Eclipse's Tomcat plugin is downloaded in http://www.sysdeo.com/eclipse/tomcatpluginv2.zip

installation:

1. Install JDK1.4

2. Install Tomcat4.0

3. Install Eclipse 2.0, unzipped

4. Decompose TomcatPluginv2.zip to copy the com.sysdeo.eclipse.tomcat folder to the Plugins directory in the Eclipse installation directory.

Configuration:

1. Start Eclipse

2. Open Menu Windows-> Preferencees

3. Select Tomcat on the left, you can see some forms appear on the right.

4. Tomcat Version Selects Version 4.0.x, Tomcat Home Select Tomcat's installation path, and automatically fill in Tomcat configuration file server.xml in the Configuration file.

5. Expand the Tomcat menu on the left, select JVM Settings, JRE Select Detected VM,

6. Press APPLY

7. Press OK

8. Look at your toolbar, don't have a few kittens icons. If you don't, select Menu Windows -> CustMize Perspective, expand the Other option, tick on Tomcat, ok, see the kitten icon.

9. Try the Start Tomcat button, ok, Tomcat launched in Console.

example:

Be a Hello World

1. Select File-> New-> Project

2. Select Tomcat Project in the dialog, then Next

3. Enter Project Name, here you can write HelloWorld, continue next

4. Hook the Can Update Server.xml File option, finish, ok, a POJECT has been created.

5. Open the New Class Wizard, fill in HelloWorld in Name, fill in javax.servlet.http.httpservlet.http.httpservlet in SuperClass, press Finish, ok, a servlet is created.

6. Remove the Doget method in HelloWorld.java, the code is as follows:

Import javax.servlet.http.httpservlet;

Import javax.servlet.http.httpservlet;

Import javax.servlet.http.httpservletRequest;

Import javax.servlet.http.httpservletResponse;

Import java.io.ioException;

Import java.io.printwriter; import javax.servlet.servletException;

Public class helloworld extends httpservlet {

Public void doget (httpservletRequest request, httpservletResponse response)

THROWS IOException, servletexception {

Response.setContentType (Text / HTML ");

PrintWriter Writer = response.getwriter ();

Writer.println ("Hello World!");

}

}

8.ctrl s Save, Right to HelloWorld Project, select Tomcat Project-> Update Context to Server.xml

7. Start Tomcat in Eclipse

9. Access http: // localhost: 8080 / helloworld / servlet / helloworld / servlet / helloworld

10. How, see HelloWorld is not

转载请注明原文地址:https://www.9cbs.com/read-26033.html

New Post(0)