Eclipse tomcat Web page debugging

Source: Internet
Author: User
Visual Age for Java is a Java IDE development environment developed by IBM. As early as a few years ago, the Java Development Platform has accounted for half of the country, and the latest version has not been released for a long time, Because IBM has invested heavily in the research of the Eclipse project, many Java developers must have noticed this point. Eclipse is a development source code project. It is actually a substitute for Visual Age for Java. Its interface is similar to the previous Visual Age for Java. However, due to its open source code, anyone can get it for free (official website in http://www.eclipse.org/), and can develop their own plug-ins on this basis, so it is becoming increasingly popular. Many large companies, including Oracle, have recently joined the project and declared that Eclipse will become an IDE integrator that can be developed in any language 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 Visual Age for Java, according to the author's usage in J2EE development, plug-and-play is even more out-of-the-box. By downloading a Tomcat plug-in, you can easily call an external independently installed Apache Tomcat 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!

First go to http://www.sysdeo.com/eclipse/atatplugin.html to download the atatplug-in, and then decompress it to the Eclipse plugins directory. Then start Eclipse and select "mimize Perspective…" in the "Window" menu in IDE ...", Expand the Other node in the pop-up window. You can see the Tomcat option below. Click "OK" to close the window. After completing this step, there will be changes in the IDE tool bar. 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 settings and select the Tomcat version you have installed correctly, specifies the main directory of Tomcat and the server of Tomcat. xml configuration file, expand Tomcat, select the following JVM Setting, select JRE as "Detected VM", and press "OK" to close the window. Here, all the configuration work is done. You can simply press the kitten icon to start Tomcat? In the onsole window, "Starting service Tomcat-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 "Tomcat Prject" and then press "Next" until the end, 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 file. 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) is equal to the following. The Servlet code and web. xml deployment descriptor are shown as follows:

Public class TestServlet extends HttpServlet {
Private static final String CONTENT_TYPE = "text/html; charset = GBK ";
Public void doGet (HttpServletRequest request, HttpServletResponse response)
Throws ServletException, IOException {
Response. setContentType (CONTENT_TYPE );
PrintWriter out = response. getWriter ()

Int n = 1;
For (int I = 1; I <= 5; I ++ ){
N * = I;
}

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

<? Xml version = "1.0" encoding = "UTF-8"?>
<! DOCTYPE web-app PUBLIC "-// Sun Microsystems, Inc. // DTD Web Application 2.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 file, and type "http: // 127.0.0.1: 8080/ServletDemo/TestServlet" in the browser to see "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 who are familiar with Visual Age for Java should understand the following process. Follow F6 to find the next statement and press F5 to follow up the call process.

Transfer http://soft.yesky.com/55/2272055.shtml above

Note:

1. Do not check don't run tomcat in debug mode on Windows> preference> tomcat> JVM setting.

 

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.