In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces "how to use jetty under MyEclipse 6.5". In daily operation, I believe many people have doubts about how to use jetty under MyEclipse 6.5. the editor consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful to answer the questions of "how to use jetty under MyEclipse 6.5". Next, please follow the editor to study!
If a person is asked to name an open source Servlet container, his answer may be Apache Tomcat. But Tomcat is not alone. We still have Jetty. Jetty is an open source Servlet container written in the Java language that provides a runtime environment for Java-based web content such as JSP and Servlet. Jetty as an optional Servlet container is just an additional feature, and it is really famous because it is designed as a Servlet container that can be embedded in other Java code. That is, the development team provides Jetty as a set of Jar files, so you can instantiate the Servlet container into an object in your own code and manipulate the container object.
Jetty is not a new face in the Servlet container, it has come to the fore since 1998. The release of Jetty follows the open source agreement of Apache 2.0, and you can use Jetty in both free and commercial software.
Environment: Windows XP + JDK 1.6.11 + MyEclipse 6.5 + jetty-7.0.0pre3
1. Open myEclipse, create a new java project Jetty, establish webapps and logs folders (at the same level as src), config, Servlet and test folders under src, and manage directory as web working directory in webapps.
two。 Add three jar packages under ${ROOT}\ jetty-7.0.0pre3\ lib to the classpath of the project, and add four jar packages under ${Root}:\ jetty-7.0.0pre3\ lib\ jsp-2.1 to jetty.xml, webdefault.xml and realm.properties under classpath,copy$ {ROOT}\ jetty-7.0.0pre3\ etc of the project to src\ config, and test.xml under copy$ {ROOT}\ jetty-7.0.0pre3\ contexts to src\ config and rename manage.xml.
3. Modify jetty.xml and manage.xml, change the path with jetty.xml, webdefault.xml and realm.properties in these configuration files to src\ config, and create a new index.jsp under webapps/manage.
4. Create a new Start.java under the test directory as follows:
Import org.mortbay.jetty.*; import java.io.*; import org.mortbay.jetty.handler.*; import org.mortbay.xml.*; public class start {public static void main (String args []) {Server server = new Server (8080); server.setHandler (new DefaultHandler ()); XmlConfiguration cfg = null; try {cfg = new XmlConfiguration (new FileInputStream (". / src/com/greysh/config/jetty.xml")); cfg.configure (server); server.start () System.out.println ("Jetty Started...");} catch (FileNotFoundException e) {e.printStackTrace ();} catch (IOException e) {e.printStackTrace ();} catch (Exception e) {e.printStackTrace ();}
Run the Start class, access http://localhost:8080/, with IE, click / manage-- > org.mortbay.jetty.webapp.WebAppContext@1275d39 {/ manage,file:/D:/Program%20Files/MyEclipse%206.5/workspace/Jetty/webapps/manage/}, and Jetty will run successfully.
If you want to run servlet in Jetty, the procedure is as follows:
1. Create WEB-INF under webapps/manage, and create a new web.xml to configure servlet, and copy the contents of webdefalut.xml under contexts to web.xml.
two。 Modify the manage.xml under contexts, write the jsp program in the webapps directory, write the corresponding servlet handler in the servlet directory, and configure it in web.xml.
3. Run the Start class and visit http://localhost:8080/, with IE. Click / manage-> org.mortbay.jetty.webapp.WebAppContext@bb05de
Run servlet successfully to this Jetty
At this point, the study on "how to use jetty under MyEclipse 6.5" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.