In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article introduces the knowledge of how to use jetty under MyEclipse 6.5. in the operation of practical cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
The whole process of using jetty under MyEclipse 6.5.
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 At the same time, test.xml under copy ${ROOT}\ jetty-7.0.0pre3\ contexts to src\ config and renamed to 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:
1 import org.mortbay.jetty.*;2 3 import java.io.*;4 5 import org.mortbay.jetty.handler.*;6 7 import org.mortbay.xml.*;8 9 public class start {10 11 public static void main (String args []) {12 13 Server server = new Server (8080); 14 15 server.setHandler (new DefaultHandler ()); 16 17 XmlConfiguration cfg = null;18 19 try {20 21 cfg = new XmlConfiguration (new FileInputStream (". / src/com/greysh/config/jetty.xml")) 22 23 cfg.configure (server); 24 25 server.start (); 26 27 System.out.println ("Jetty Started..."); 28 29} catch (FileNotFoundException e) {30 31 e.printStackTrace (); 32 33} 34 35 catch (IOException e) {36 37 e.printStackTrace (); 38 39} catch (Exception e) {40 41 e.printStackTrace (); 42 43} 44} 45} 46 47}
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
That's all for "how to use jetty under MyEclipse 6.5.Thank you for reading." If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
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.