我根据文档写了一个简单的https servlet与Jetty,由于某些原因它不起作用。没有错误消息,没有...浏览器连接到servlet,但就是这样 - 连接后它永远挂起。这是代码:
SslSocketConnector sslConnector = new SslSocketConnector();
sslConnector.setPort(5555);
sslConnector.setKeystore(null);
sslConnector.setHost("localhost");
((AbstractConnector) connector).setThreadPool(new QueuedThreadPool(20));
server.addConnector (sslConnector);
ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
context.setContextPath("/");
HandlerList handlers = new HandlerList();
handlers.setHandlers(new Handler[] {context, new DefaultHandler() });
server.setHandler(handlers);
MyServlet servlet = new MyServlet();
context.addServlet(new ServletHolder(servlet), "/*");
server.start();
server.join();
答案 0 :(得分:1)
sslConnector.setKeystore(空);
对于SSL连接,您需要添加SSL证书,该证书可以使用JDK中提供的工具生成。
见
http://download.oracle.com/javaee/1.4/tutorial/doc/Security6.html