1 Jetty 简介
Jetty 是一个开源的servlet容器,它为基于Java的web内容,例如JSP和servlet提供运行环境。Jetty是使用Java语言编写的,它的 API以一组JAR包的形式发布。开发人员可以将Jetty容器实例化成一个对象,可以迅速为一些独立运行(stand-alone)的Java应用提供网络和web连接。
Jetty 可以作为嵌入式服务器使用,Jetty的运行速度较快,而且是轻量级的,可以在Java中可以从test case中控制其运行。从而可以使自动化测试不再依赖外部环境,顺利实现自动化测试。 Jetty is an open-source, standards-based, full-featured web server and servlet container implemented entirely in Java. It is released under the Apache 2.0 licence and is therefore free for commercial use and distribution. 2 Jetty 下载安装,启动与关闭
下载: http://jetty.mortbay.org/jetty/ 目前的稳定版是 Jetty6,建议项目中使用此版本
安装: 和zip版的tomcat几乎一样,解压到你自己的目录即可
根目录下与操作密切相关的主要为: (1 start.jar 用于启动jetty,最简单的方法:
Shell代码
java -jar startup.jar
java -jar startup.jar
这种方式等同于下面的启动方式; 关闭时ctrl+c 即可 !
Running jetty6 is as simple as going to your jetty installion directory and typing:
java -jar start.jar etc/jetty.xml
This will start jetty and deploy a demo webapp available at:
http://localhost:8080/test
Stopping
Apart from stopping jetty with a cntrl-c in the same terminal window as you started it, you can
start Jetty so that it listens on a local port for stop commands:
If the STOP.KEY property is ommitted from the start command, then a random key is printed on standard out. If the STOP.PORT is set to 0, a random available port is assigned and printed on stdout.