JettyJetty is an open source servlet container that provides a running environment for java-based web containers, such as JSPs and servlet. Jetty is written in the Java language, and its APIs are published in the form of a set of jar packages. Developers can instantiate an jetty container as an object and quickly provide network and web connectivity for some standalone-run (stand-alone) Java applications.
characteristic
Ease of useEase of use is the basic principle of Jetty design, Ease-of-use is mainly embodied in the following aspects: through the XML or API to configure the Jetty, the default configuration can meet most of the requirements, the Jetty embedded in the application only need very little code;
ScalabilityIn applications that use Ajax WEB 2.0, each connection needs to stay longer so that the consumption of threads and memory increases dramatically. This makes us worry that the entire program will affect the performance of the entire program because a single component is stuck in a bottleneck. But with the Jetty: Even in the case of a large number of service requests, the performance of the system can be maintained in an acceptable state. The continuation mechanism is used to handle a large number of user requests and long connections. In addition, Jetty has designed a very good interface, so that when some implementations of Jetty do not meet the needs of users, users can easily modify some of the Jetty implementations to make Jetty applicable to the needs of particular applications.
Ease of embeddingJetty design is designed as an excellent component, which means that Jetty can be easily embedded in the application without the need for a program to make changes to use Jetty. In a way, you can also interpret Jetty as an embedded Web server. Jetty can be used as an embedded server, Jetty runs faster and is lightweight, and can be controlled from test case in Java. So that automated testing can no longer rely on the external environment, the smooth implementation of automated testing.
and Tomcat comparisons.
Original address: Jetty and Tomcat selection: According to the scenario [1] 1) jetty lighter. This is relative to Tomcat. Because Tomcat, in addition to following the Java servlet specification, has extended a large number of JEE features to meet the needs of enterprise-class applications, Tomcat is heavier and much more complex than jetty. But for a large number of ordinary Internet applications, Tomcat does not need to use other advanced features, so in this case, the use of Tomcat is a waste of resources. This disadvantage is placed in the distributed environment, is more obvious. Instead of jetty, each application server saves a few megabytes of memory, saving a significant amount of resources for a large, distributed environment. Also, the lightweight of jetty makes it faster and more efficient to handle high concurrent fine-grained requests. 2 jetty more flexible, embodied in its pluggable and scalable, it is easier for developers to jetty itself to develop two times, customizing a Web Server for their own needs. By contrast, heavyweight Tomcat originally supported too many features, and the cost of losing weight was much greater than the cost of jetty. With your own understanding, that is, increasing weight is easy to reduce the difficulty. 3 However, when it comes to supporting large-scale enterprise applications, jetty may need to expand, and in this scenario Tomcat is better. Summary: Jetty is more responsive to the needs of the public cloud's distributed environment, while Tomcat is more in line with enterprise-class environments.
Code Instances
Using code instance Java code as an embedded server
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17-18 |