Answer the question
In order to leave comments, you need to log in
How to properly configure Jetty 9 embedded?
This is how I run Jetty embedded.
QueuedThreadPool threadPool = new QueuedThreadPool(50, 10);
Server server = new Server(threadPool);
ServerConnector connector = new ServerConnector(server);
connector.setIdleTimeout(30000);
connector.setPort(8000);
ServletContextHandler context0 = new ServletContextHandler(ServletContextHandler.NO_SESSIONS);
context0.setContextPath("/cameraImages");
context0.addServlet(new ServletHolder(new MyServlet(this.images)), "/*");
server.setHandler(context0);
server.addConnector(connector);
try {
server.start();
server.join();
} catch (Exception e) {
e.printStackTrace();
}
Answer the question
In order to leave comments, you need to log in
I can:
public class MyServlet extends HttpServlet {
private final ConcurrentMap<Integer, String> images;
private final static String RESPONSE_TYPE = "text/plain";
private final static String ID_KEY = "id";
private final static String JPEG_KEY = "jpeg";
private final static Logger log = Logger.getLogger(MyServlet.class);
public MyServlet(ConcurrentMap<Integer, String> images) {
this.images = images;
}
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse response) throws ServletException, IOException {
response.setContentType(RESPONSE_TYPE);
String img = null;
ImagesToJSON itj = new ImagesToJSON();
img = itj.toString(images);
if (img == null) {
response.setStatus(HttpServletResponse.SC_NOT_FOUND);
return;
}
response.getWriter().println(img);
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question