Using the JDB debugger

Source: Internet
Author: User

You can use the Debug applet or the application's JDB command to debug the Servlet.

To debug a servlet, we can debug sun.servlet.http.HttpServer and then treat it as a httpserver execution servlet in response to the browser's HTTP request. This is very similar to debugging applet applets. Unlike debugging applets, the actual program being debugged is sun.applet.AppletViewer.

Most debuggers automatically hide the details of how to debug applets. Similarly, for servlets, you must help the debugger do the following:

    • Set your debugger's classpath classpath so that it can find sun.servlet.http.http-server and related classes.
    • Set your debugger's classpath classpath so that it can find your servlet and supported classes, typically in Server_root/servlets and server_root/classes.

You typically do not want server_root/servlets in your classpath because it disables the re-loading of the servlet. However, this inclusion rule is very useful for debugging. It allows your debugger to set breakpoints in the servlet before the custom servlet loader in httpserver loads the servlet.

If you have set the correct classpath classpath, you can start debugging Sun.servlet.http.HttpServer. You can set breakpoints in the Servlet code that you want to debug, and then use a given servlet (Http://localhost:8080/servlet/ServletToDebug) to make a request to httpserver through a Web browser. You will see that the program execution stops at the breakpoint.

Using the JDB debugger

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.