Install and debug Tomcat plug-in on Eclipse

Source: Internet
Author: User
Visualageforjava is a Java Development Environment developed by IBM. As early as a few years ago, Java R & D platforms accounted for half of the country, and a new version has not been released for a long time recently, Because IBM has invested heavily in Eclipse project research, many Java developers must have noticed this. Eclipse is a development source code project, he is actually a substitute for visualageforjava, its interface is similar to the previous visualageforjava, but because of its open source code, anyone can get free (Official Website http://www.eclipse.org /), and the ability to develop their own plug-ins on this basis, so more and more people are concerned. Many large companies, including Oracle, have recently joined the project and declared that eclipse will become an IDE builder for any language development in the future. Users only need to download plug-ins in various languages.

No matter whether eclipse can become a true integrator or not, eclipse has become more powerful than the previous visualageforjava, according to the author's use in J2EE R & D, plug-and-play is even more out-of-the-box. By downloading a tomcat plug-in, you can easily call the external independently installed apachetomcat for JSP and Servlet debugging. Let's take a look at how easy it is to add tomcat to eclipse to track and debug servlets!

We need to go to ingress first. Then start eclipse and select "customizeperspective…" in the "window" menu in IDE ...", Expand the other node in the pop-up window and you can see the Tomcat option below. Click "OK" to close the window. After completing this step, there will be changes in the IDE toolbar. Are you excited to see the cute tomcat kitten icon! But don't rush to press the kitten button. You also need to go to "Preferences" in the "window" menu to make some configuration and select the tomcat version you have installed correctly, specifies the main directory of Tomcat and the server of Tomcat. xml configuration document, expand tomcat, select the following jvmsetting, select JRE as "detectedvm", and press "OK" to close the window. So far, all the configuration work has been done, and you can see it by pressing the kitten icon to start Tomcat? In the onsole window, "startingservicetomcat-standalone……" appears ......" Tomcat startup information.

After successful startup, we will make a simple servlet for testing. Select the "project" menu under "file" of IDE. Be sure to select "atatprject" and then press "Next" until the end, in the meantime, enter the servlet name, working directory, and other information according to the window prompts, and select whether to automatically update the server. XML. For simplicity, we choose to automatically update the server. XML document. The virtual directory name is servletdemo. Add your own servlet class to the project. As an example, the author defines a simple testservlet class to calculate 5! (5 factorial) equal to, ServletCodeAnd the Web. xml deployment descriptor are as follows:

Publicclasstestservletextendshttpservlet {

Privatestaticfinalstringcontent_type = "text/html; charset = GBK ";

Publicvoiddoget (httpservletrequestrequest, httpservletresponseresponse)

Throwsservletexception, ioexception {

Response. setcontenttype (content_type );

Printwriterout = response. getwriter ()

INTN = 1;

For (INTI = 1; I <= 5; I ++ ){

N * = I;

}

Out. println ("<HTML> ");

Out. println ("

Out. println ("<body> ");

Out. println ("<p> 5! = "+ N +" </P> ");

Out. println ("</body>

Out. Close ();

}

}

<? Xmlversion = "1.0" encoding = "UTF-8"?>

<! Doctypeweb-apppublic "-// sunmicrosystems, Inc. // dtdwebapplication2.2 //" http://java.sun.com/j2ee/dtds/web-app_2_2.dtd ">

<Web-app>

<Servlet>

<Servlet-Name> testservlet </servlet-Name>

<Servlet-class> testservlet </servlet-class>

</Servlet>

<Servlet-mapping>

<Servlet-Name> testservlet </servlet-Name>

<URL-pattern>/testservlet </url-pattern>

</Servlet-mapping>

</Web-app>

Save the above Code and XML description, and type "http: // 127.0.0.1: 8080/servletdemo/testservlet" in the browser to view "5! = 120 ", right?

Next we set a breakpoint in the line "N * = I;" to track the computing process. Press the refresh button in the browser window and return to the eclipsep window. Is there a blue line in the breakpoint line? Readers familiar with visualageforjava should understand the following process. Follow F6 to find the next statement and press F5 to follow up the call process.

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.