Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jetty-users] [HELP] How can i run WebAppContext with WebSocketHandler in same instance?

May be there is any alternative solutions? If nobody is answering…

On 5 Jul 2014, at 14:29, Dmitry Polovka <messaged@xxxxxxxxxxx> wrote:

> Hey, i’m literally 3 weeks in Java community transitioning from PHP.
> I experience problem with configuring Jetty server to run WebAppContext with WebSocketHandler.
> I tried to add WebSocketHandler to WebAppContext as parent handler, bind two handlers via HandlerCollection, but i clearly do something wrong.
> Here is my default WebAppContext configuration:
> public static void main(String[] args) throws Exception
> {
> 	ServerConnector connector = new ServerConnector(server);
> 	connector.setPort(8080);
> 	server.addConnector(connector);
> 	WebAppContext context = new WebAppContext("webapp", "/");
> 	// Setting up browser caching. Binds params for org.eclipse.jetty.servlet.DefaultServlet.init()
> 	context.getInitParams().put("org.eclipse.jetty.servlet.Default.etags", "true");
> 	context.getInitParams().put("org.eclipse.jetty.servlet.Default.cacheControl", "public, max-age=0");
> 	// Will throw an exception when will be unable to start server for some reason
> 	context.setThrowUnavailableOnStartupException(true);
> 	server.setHandler(context);
> 	server.start();
> 	server.join();
> }
> My goal is to add web socket support. May be to some /ws address, but on same port as main instance. Which options do I have?

Back to the top