Tomcat and Eclipse Debugging servlet tutorial

Source: Internet
Author: User

This tutorial will teach you the setup process for debug a simple servlet with Tomcat in Eclipse. There are many plug-ins in eclipse that can help you configure, and they are basically trying to automate the content described in this tutorial.

It is a pleasure to know what is happening under the surface.

Note: This tutorial does not describe how you can make real debug, and for real debug, please go to the Tutorial Debug.

Body

For starters, the Debug configuration process for a servlet can cause panic and complex moods. However, in this tutorial, I'll give you a clear picture of how to debug and trigger a debug session in Tomcat.

content

Debug a Web program contains the following content.

Application Server

In general, all application servers support debug mode, and you can only run it when you start the server, which will open a debug service (the port is typically 8000). You can connect to this port to debug your program. In this tutorial I will show you how to activate Tomcat's debug mode.

IDE

You can debug your program with the default command-line debugger, which will give you a complete way to access the debugger and debug the software. Using the IDE for debug will make debug easier. In this case, the IDE tool and the debug port of the application server (typically 8000) establish a TCP/IP connection. In this example, I'll describe how to configure eclipse so that you can debug in tomcat.

Debugger

A debugger is an external software that allows you to debug your program, and it will run on the application server. The vast majority of application servers have been configured with a debugger, and the pre-installed debugger in Tomcat is jdb.

Code for Debug

Your code will be allowed in Tomcat and I will not elaborate on how to deploy your application. You can use the methods described in this tutorial to run applications in the application server without any restrictions on debug.

You may notice that the application server and the IDE connect using the TCP/IP protocol, which means that Tomcat and IDE tools are not needed to run on the same machine, and you don't even need them in the same one weeks. As long as you can access the Internet to the server, you can even debug any application anywhere in the world. This is not the coolest thing in history.

set the debug mode for Tomcat

For Debug,tomcat has everything, you just write the following command (Windows system, other system commands and similar), Tomcat's debug mode is available.

Set jpda_address=8000 set Jpda_transport=dt_socket catalina.bat JPDA start

Make sure that the above command is executed in the {Catalina_home}/bin directory, and for simplicity I usually generate a shell script (a. bat file) to perform automatically.

I named this file Debugmode.bat, which contains three lines of code, which I usually put in the {Catalina_home}/bin directory. You can then double-click the file to start the Tomcat debug mode.

deploy your application to a server

In order to debug your program, you must deploy the application to the server in a normal way. No longer dwell on this.

Connect Tomcat and Eclipse for debug

Follow these simple steps to connect Eclipse and Tomcat debugging services.

1. Start Eclipse

2. Open the project that contains the servlet you want to debug

3. Click on the small arrow next to the Debug button to see the Pull-down menu

4. Click on "Open Debug Dialog ..." (It may also be "debug configurations ...")

1, in the Debug window, click on the left-hand list of "Remote Java application"

1. For debug files, choose a name (just for yourself to be able to easily differentiate)

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.