I use jetty for my server. I just wonder if there is a way to manage (get count , list connection, force disconnect) connection ?
For example : i want verify client before it connect and then disconnect a client if the authentication failed, how to do that ?
server = new Server();
ServerConnector httpConnector = new ServerConnector(server);
httpConnector.setPort(utils.server_listen_port);
httpConnector.setIdleTimeout(5000); //
httpConnector.setHost(listen_interface); // <--------- !
server.addConnector(httpConnector);
ServletContextHandler handler = new ServletContextHandler(server, "/");
hello h0 = new hello(); h0.bind_to_server(handler, "/");
public class hello extends HttpServlet{
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
try {
if (!req.getParameter("key").equals("123"){
disconnect the client!
}
... do other thing
} catch (Exception e) {
e.printStackTrace();
write_response....(resp, "ERROR Exception " + e.getMessage());
}
}
}