Eclipse + Tomcat web program development

Source: Internet
Author: User

Environment: Windows 7 + eclipse Java ee ide for Web developers + Tomcat 7.02

Tomcins: atatpluginv321.zip

1. Configure the Tomcat plug-in

Create a myplugins folder to store the plug-ins. myplugins are located in the D:/program files/J2EE directory. Eclipse installation path: D:/program files/J2EE/eclipse-javaee. Tomcat installation path: D:/program files/J2EE/Apache-Tomcat-7.0.2. Therefore, myplugins, eclipse-javaee, and tomcat are located in the same directory. Of course, this is not necessary. It is easy to manage.

Create the directory where you want to store Tomcat plug-ins: D:/program files/J2EE/myplugins/tomcatpluginv321/Eclipse/plugins. then, run com in tomcatpluginv321.zip. sysdeo. eclipse. unzip tomcat_3.2.1 to the d:/program files/J2EE/myplugins/tomcatpluginv321/Eclipse/Plugins directory. Here Eclipse/plugins are required.

Create another links folder under eclipse-javaee, and then create a tomcat. Link file under the links folder. You can create a text file and save it as Tomcat. Link. Open tomcat. Link in notepad and enter: Path = D: // program files // J2EE // myplugins // tomcatpluginv321.

At this time, the external configuration of Tomcat is complete, and then open eclipse. At this time, we will find that eclipse has a small Tomcat icon.

Then, choose Window> preferences in eclipse to open the interface shown in

Enter the Tomcat base address in the Advanced tab of Tomcat, that is, the tomcat installation address.

At this time, we can start Tomcat through the Tomcat small icon in the eclipse menu bar.

2. Configure the eclipse Server

Like tomcat configuration, it is also configured under window> preferences in eclipse, as shown in:

Only the server that configures Tomcat can be published through tomcat. The Tomcat plug-in configured earlier only enables us to quickly start Tomcat in eclipse configuration. The website is configured in this step. As shown in, we have configured two Tomcat servers, namely, Tomcat 6.0 and tomcat 7.0. We can decide which server to use as needed. This configuration server is actually very simple, just add it. As shown in:

After configuring the server, we will use them later.

3. Create a web application

Next, create a web project, as shown in

In this way, a dynamic web application is created.Program. From the above we can see that there is a target runtime option, this option is the server we created earlier, here we choose Tomcat 6.0, after target Runtime is selected, eclipse automatically selects the dynamic Web module version and configuration options. By default, you can click Finish to create the project. Create an index. jsp file in the webcontent directory of the Project testtomcat2 created. As shown in:

4. Publish Web Applications

Right-click Project testtomcat2 and choose run as> run on server, as shown in:

Click Finish to complete the release. After the release, the released project is automatically opened in eclipse, as shown in:

The above is the whole process of publishing Web applications through eclipse and tomcat.

 

PS: Notes

Using plug-ins in eclipse to configure Tomcat and using server to configure Tomcat are two different concepts. To publish a web application, you must use the server. To start Tomcat, you can use the plug-in, however, you do not need to use the plug-in to configure Tomcat on the server.

A problem found during debugging today is that you can use the plug-in to start Tomcat and then open http: // localhost: 8080 in the browser to open the Tomcat homepage, however, if you use the server to start Tomcat, you cannot open this homepage in the browser, but if a project is published in Tomcat, you can open this project. For example, you can open the index. jsp file under the project http: // localhost: 8080/demo. The reason is that the server. xml configuration is incorrect, but I cannot make it clear.

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.