Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[jetty-users] Connection Manager

Hi!

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 ?

my code like this : 
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());
}
}
}

Back to the top