Original source: http://blog.chenlb.com/2009/01/quick-start-jetty-and-embed-in-project.html
See open source projects with a JSP container (jetty) when they are released. Take to do demo, development, debugging server is still very good. Try it today and run it mainly.
First step Download: Http://dist.codehaus.org/jetty/jetty-6.1.14/jetty-6.1.14.zip is currently the latest stable version. Decompression to such as E:\jetty-6.1.14, among which the more important directory is: etc, contexts, WebApps. The Conf, Conf\catalina\localhost, WebApps directories that the individual believes can be analogous to Tomcat. Contexts is used for heat deployment.
Under trial run, you can put a simple Web project into the WebApps directory, or *.war, such as: Web-demo (or Web-demo.war) into the WebApps directory.
E:\jetty-6.1.14>java-jar Start.jar
2009-01-13 15:34:38.937::info:logging to STDERR via Org.mortbay.log.StdErrLog
2009-01-13 15:34:39.265::info:jetty-6.1.14
2009-01-13 15:34:39.421::info: Deploy E:\jetty-6.1.14\contexts\javadoc.xml-Org.mortbay.jetty.handler.contexthandler@15cda3f{/javadoc,file :/e:/jetty-6.1.14/javadoc/}
...
2009-01-13 15:35:01.828::info:opened E:\jetty-6.1.14\logs\2009_01_13.request.log
2009-01-13 15:35:01.953::i Nfo:started selectchannelconnector@127.0.0.1:8080
Open: Http://localhost:8080/web-demo, well, there's a result.
If you do not put the Web-demo in the WebApps directory can also, in the contexts directory to create a file to tell Jetty on the line. You can copy Test.xml to web-demo.xml under the contexts directory, and then modify the following:
1.<?xml version= "1.0" encoding= "iso-8859-1"?> 2.<!
DOCTYPE Configure Public "-//mort Bay consulting//dtd configure//en" "Http://jetty.mortbay.org/configure.dtd" > 3.
4.<configure class= "Org.mortbay.jetty.webapp.WebAppContext" > 5. 6. <!------------------------------------> 7. <!--Required Minimal context configuration:--8. <!--+ ContextPath-9. <!--+ War OR resourcebase-10. <!------------------------------------> 11. <set name= "ContextPath" >/web-demo</Set> 12.
<set name= "war" >e:/workspace/web-demo/WebContent</Set> 13. <!------------------------------------> 15. <!--Optional Context Configuration---16. <!------------------------------------> 17. <set name= "Extractwar" >false</set> 18. <set name= "Copywebdir" >false</Set> 19. <set name= "Defaultsdescriptor" > 20. <systemproperty name= "Jetty.home" default= "."/>/etc/webdefault.xml</set> 21. <!--22. <set name= "Overridedescriptor" ><systemproperty name= "Jetty.home" 23. Default= "." />/contexts/test.d/override-web.xml</set> 24. -25.</configure>
The
War can be set to an absolute path. Then restart jetty and try again. Okay, here's a preliminary understanding of jetty.