ZengCode.Com (The Thai Php Framework)  


Home   Download   Manual   About us    

Facebook   


MAIN MENU
เขียนโปรแกรมบน iPhone ด้วย MonoTouch
News
Php Tips
Ubuntu
Spring+Strut+Hibernate
Android Programming
Design Pattern By PHP
C# Design Pattern
Linux Quick Tips
C# Tips & Technique
C# using Linq น่าใช้จริงๆ
Java & JavaScript Tips
MAVEN
Database & SQL
ZengCode Framework Guide
Mac OSx
Zeng Code Code
Programming
IPhone (Tips and Trick)

Download เอกสารที่น่าสนใจ

     วิธี Embbed Jetty Server ให้ run website ใน application ของเรา  (2011-05-20)

วิธี Embbed Jetty Server  ให้ run website ใน application ของเรา
ซึ่งเอาจะเอาไว้ใช้ในการเทส หรือทำ Editor ให้สามารถรัน Embbed Web Server เหมือน Eclipse หรือ NetBean
และผมว่าก็สามารถเอาไปประยุกต์ใช้งานได้มากมายเลยนะครับ ลองเอาไปประยุกต์ใช้กันดูนะครับ โอ๊ยๆๆๆๆๆๆๆๆ ผมรัก JAVA

.......
import org.mortbay.jetty.Connector;
import org.mortbay.jetty.Server;
import org.mortbay.jetty.bio.SocketConnector;
import org.mortbay.jetty.webapp.WebAppContext;


public class MyJettyTest {
    private Log log = LogFactory.getLog(MyJettyTest.class);

        private Server server;

        @Before
        public void setUp() throws Exception {

         server = new Server();
         SocketConnector connector = new SocketConnector();
         connector.setPort(8089); //ระบุ port ที่ต้องการ
         server.setConnectors(new Connector[] { connector });
         WebAppContext context = new WebAppContext();
         context.setServer(server);
         context.setContextPath("/zeng");
         context.setWar("xxxxxx/webapp/zeng.war"); //ตัวนี้ คือ webapp ที่เราพัฒนาและต้องการ deploy นะครับ
         server.addHandler(context);
         server.start();

        }

   @After
   public void tearDown() throws Exception {
            server.stop();
   }

     @Test
    public void testPresenceOfIndexPage() throws Exception {
         URL url = new URL("http://localhost:8089/zeng/");
         URLConnection yc = url.openConnection();
         BufferedReader in = new BufferedReader(
                                 new InputStreamReader(
                                 yc.getInputStream()));
         String inputLine;
         while ((inputLine = in.readLine()) != null)
            System.out.println(inputLine); //ตรงนี้ก็จะ loop content ที่ webapp response กลับมานะครับ
         in.close();
    }


}

 


 


Comment

PEA  (22 พฤษภาคม 2554)   
IP : 124.120.153.161

ถูกต้มครับน้องแมค คิคิ



Mac  (20 พฤษภาคม 2554)   
IP : 101.108.73.50

 ลืมถาม @After จะทำงานหลัง @Test จบรึป่าวคับ

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 



Mac  (20 พฤษภาคม 2554)   
IP : 101.108.73.50

ขอบคุณคับ :) 

tle="like thumb thumbs up up vote icon" class="iconlink" href="http://www.iconfinder.com/icondetails/64879/32/like_thumb_thumbs_up_up_vote_icon" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'helvetica neue' arial sans-serif; color: rgb(47 74 144); text-decoration: none; ">like thumb thumbs up up vote icon

 


Name
Comment
Security CodeCAPTCHA Image

web hit counter

This page took 0.042538 seconds to load.