Eclipse + Tomcat Integrated Development Servlet
Keyword: Eclipse Tomcat Servlet
Eclipse is an integrated development environment of open source, which is strongly supported by IBM, while Tomcat is more familiar to us. It is a JSP/servlet container organized by Apache, the following describes how to integrate:
Preparation:
1. tomcat4.0
2. jdk1.4
3. eclipse2.0
4. Eclipse Tomcat plug-in can be downloaded at http://www.sysdeo.com/eclipse/tomcatpluginv2.zip
Installation:
1. Install jdk1.4
2. Install tomcat4.0
3. Install eclipse2.0 and decompress it.
4. Decompress atatpluginv2.zip and copy the com. sysdeo. Eclipse. Tomcat folder to the Plugins directory under the eclipse installation directory.
Configuration:
1. Start eclipse
2. Choose Windows> preferences.
3. Select Tomcat on the left side. Some forms are displayed on the right side.
4. Select version 4.0.x for tomcat version, and tomcat home select the tomcat installation path. The configuration file will automatically fill in the tomcat configuration file server. xml.
5. Expand the Tomcat menu on the left, select JVM settings, and select detected Vm for JRE,
6. Press Apply.
7. Press OK.
8. check whether there are a few more kitten icons in your toolbar. If not, choose windows> custmize perspective from the menu, expand the other option, and check tomcat, the kitten icon does not exist.
9. Try the start Tomcat button. All right, Tomcat is started on the console.
Example:
The following is an example of Hello world.
1. Select File> New> project.
2. Select Tomcat project in the dialog box, and then click
3. Enter the project name. Here you can write helloworld and continue next.
4. Check the can update server. xml file option, finish, and a poject has been created.
5. Open the New Class Wizard, enter helloworld in name, And javax. servlet. http. httpservlet in superclass. Press finish. A servlet is created.
6. Reload 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-click helloworld project, select Tomcat project-> Update context to server. xml
7. Start tomcat in eclipse
9. Access http: // localhost: 8080/helloworld/servlet/helloworld in a browser
10. How do I see helloworld?