詳細可參考: https://wiki.eclipse.org/Jetty/Tutorial/Embedding_Jetty
公告版位
- Nov 07 Fri 2014 20:40
在 Jetty 中使用 Servlet
- Nov 05 Wed 2014 21:04
Jetty 取得網址列參數
String name = request.getParameter("name");
- Nov 05 Wed 2014 20:49
嵌入式 Jetty 最小 Web
瀏覽器輸入 http://127.0.0.1:8888/Hello/ 即可看見效果
package server;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.handler.ContextHandler;
public class Main {
public static void main(String[] args) throws Exception {
Server server = new Server(8888);
ContextHandler context = new ContextHandler();
- Nov 03 Mon 2014 20:29
Tomcat 監聽啟動與結束 (獨立線程)
package my;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
public class NewClass implements ServletContextListener {
@Override
public void contextInitialized(ServletContextEvent sce) {
System.out.println("Start");
}
@Override
public void contextDestroyed(ServletContextEvent sce) {
- Nov 03 Mon 2014 17:06
Java 最小 Http 實作 (顯示圖片)
package main;
import java.io.*;
import java.net.InetSocketAddress;
import com.sun.net.httpserver.HttpExchange;
import com.sun.net.httpserver.HttpHandler;
import com.sun.net.httpserver.HttpServer;
public class Main {
public static void main(String[] args) throws Exception {
HttpServer server = HttpServer.create(new InetSocketAddress(80), 0);
server.createContext("/Hello", new MyHandler());