The whole process of using jetty under MyEclipse 6.5

Source: Internet
Author: User
Tags apache tomcat

If you let a person speak an open-source servlet container, his answer might be Apache Tomcat. But Tomcat is not alone, and we have jetty. Jetty is an open-source servlet container written in the Java language that provides a running environment for Java-based web content such as JSPs and Servlets. Jetty as an optional servlet container is just an extra feature, and it is really famous because it is designed as a servlet container that can be embedded in other Java code. This means that the development team provides jetty as a set of jar files, so you can instantiate the Servlet container as an object in your own code and manipulate the container object. Jetty is not a new face in the servlet container, and it has been a prominent figure since 1998. Jetty's release follows the Apache 2.0 Open source protocol, and you can use jetty in free software and commercial software. The whole process of using jetty under MyEclipse 6.5 is described below. Environment: Windows XP + JDK 1.6.11 + myeclipse 6.5 + jetty-7.0.0pre31. Open MyEclipse, create a new Java Engineering jetty, create WebApps and Logs folders (and SRC siblings), create Config, servlet, and test folders under SRC, and set up WebApps directories in manage as Web working directory. 2. Add the three jar packages under ${root}\jetty-7.0.0pre3\lib to the classpath of the project and ${root}:\jetty-7.0.0pre3\lib\ jsp-2.1 under the four Jar package joined the project under the Classpath,copy${root}\jetty-7.0.0pre3 \etc Jetty.xml, Webdefault.xml and realm.properties to Src\ Config, at the same time copy ${root}\jetty-7.0.0pre3\contexts under Test.xml to Src\config and renamed to Manage.xml. 3. Modify Jetty.xml, Manage.xml, change the path of these configuration files with Jetty.xml, Webdefault.xml, and Realm.properties to Src\config and webapps/ New index.jsp under Manage. 4. Create a new start in the test directory. Java, the code is as follows: 1. Import org.mortbay.jetty.*;2. Import java.io.*;3. Import org.mortbay.jetty.handler.*;4. Import org.mortbay.xml.*;5. public class Start {6. public static void Main (String args[]) {7. Server server = new server (8080); 8. Server.sethandler (New DefaultHandler ()); 9. Xmlconfiguration cfg = null;10. try {one. cfg = new Xmlconfiguration (New FileInputStream ("./src/com/greysh/config/jetty.xml")); Cfg.configure ( server); 13. Server.start (); 14. System.out.println ("Jetty Started ..."); 15.} catch (FileNotFoundException e) {e.printstacktrace (); 17.} . catch (IOException e) {e.printstacktrace (); catch (Exception e) {. E.printstacktrace (); 22.} 23.}24. Run Start class, Access http://localhost:8080/with IE, click/manage---> [email protected]{/manage,file:/d:/program%20files/ myeclipse%206.5/workspace/jetty/webapps/manage/}, the Jetty can run successfully at this time. If you are running a servlet in jetty, the procedure is as follows: 1. Create the Web-inf under Webapps/manage and create a new Web. XML to configure the servlet, and copy the contents of the Webdefalut.xml under Contexts to Web. Xml. 2. Modify the manage.x under contextsML, write the JSP program in the WebApps directory and write the corresponding servlet handler in the servlet directory while configuring it in Web. Xml. 3. Run Start class, Access http://localhost:8080/with IE, click/manage---> [email protected] to this jetty run servlet successfully

The whole process of using jetty under MyEclipse 6.5

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.