Jetty can be directly debugged without deployment.

Source: Internet
Author: User

I used to debug web programs. It was really hard to build tomcat. I wanted to find a simple method. I wanted to debug a servlet I wrote, I can see the book "How Tomcat works" to understand it. However, it is more convenient to use the Web Container jetty, which is recorded here.

1. Create a project

2. Copy the code and add the dependent jar.

3. Start debugging and OK.

Project style:

 

Jettystarter code:

 Package  Jetty;  Import  Org. mortbay. Jetty. connector;  Import  Org. mortbay. Jetty. server; Import  Org. mortbay. Jetty. NiO. selectchannelconnector;  Import  Org. mortbay. Jetty. webapp. webappcontext;  /**  * Jetty server startup class **  @ Author  Zhailzh  */        Public   Class  Jettystarter {  Public   Static   Void Main (string [] ARGs) Throws  Exception {  Long Begin = System. currenttimemillis (); connector Conne = New  Selectchannelconnector (); connector. setport (integer. getinteger ( "Jetty. Port", 12345 ). Intvalue (); webappcontext webapp = New Webappcontext ("Web", "/httpservlet" ); Server Server = New Server (); server. setconnectors (  New  Connector [] {connector}); server. sethandler (webapp); server. Start (); system. Out. println ( "Jetty server started, use" + (system. currenttimemillis ()-begin) + "Ms" );}} 

Dependent jar package:

Ant-1.6.5.jar
Core-3.1.1.jar
Jetty-6.1.14.jar
Jetty-util-6.1.14.jar
Jsp-2.1.jar
Jsp-api-2.1.jar
Servlet-api-2.5-6.1.14.jar

Download link: Dependent jar package

Debug debugging:

Input in the browser:

Jetty can be directly debugged without deployment.

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.