Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[jetty-users] HTTP requests not handled independently

Hi,

I have a simple problem with which I require help.

I've embedded Jetty in my project and created a simple Handler to provide web access to my program.

When it serves multiple requests at the exact same moment, the request are being mutated and not served independently. If client 1 makes a request with parameter1=a and client 2 makes a request with parameter1=b at the same time, *both* clients are served with either a OR b.

I followed the Handler tutorial and my code is as follows:

(in Main)

        Server server = new Server();

        SelectChannelConnector httpConnector = new SelectChannelConnector();
        httpConnector.setHost("127.0.0.1");
        httpConnector.setPort(8889);
        QueuedThreadPool pool = new QueuedThreadPool(50);
        httpConnector.setThreadPool(pool);
        httpConnector.setName("testing");

        server.setConnectors(new Connector[]{httpConnector});
        server.setHandler(new SelectHandler());

        server.start();
        server.join();

My handler:

public class SelectHandler extends AbstractHandler {

    public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
        baseRequest.setHandled(true);
        String param = baseRequest.getParameter("parameter1");
    }
}

What am I missing? Any help will be greatly appreciated..

Back to the top