Java Code Examples for org.eclipse.jetty.servlet.ServletContextHandler#setAllowNullPathInfo()

The following examples show how to use org.eclipse.jetty.servlet.ServletContextHandler#setAllowNullPathInfo() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HttpBindManager.java    From Openfire with Apache License 2.0 6 votes vote down vote up
/**
 * Creates a Jetty context handler that can be used to expose the cross-domain functionality as implemented by
 * {@link FlashCrossDomainServlet}.
 *
 * Note that an invocation of this method will not register the handler (and thus make the related functionality
 * available to the end user). Instead, the created handler is returned by this method, and will need to be
 * registered with the embedded Jetty webserver by the caller.
 *
 * @return A Jetty context handler (never null).
 */
protected Handler createCrossDomainHandler()
{
    final ServletContextHandler context = new ServletContextHandler( null, "/crossdomain.xml", ServletContextHandler.SESSIONS );

    // Ensure the JSP engine is initialized correctly (in order to be able to cope with Tomcat/Jasper precompiled JSPs).
    final List<ContainerInitializer> initializers = new ArrayList<>();
    initializers.add( new ContainerInitializer( new JasperInitializer(), null ) );
    context.setAttribute( "org.eclipse.jetty.containerInitializers", initializers );
    context.setAttribute( InstanceManager.class.getName(), new SimpleInstanceManager() );

    // Generic configuration of the context.
    context.setAllowNullPathInfo( true );

    // Add the functionality-providers.
    context.addServlet( new ServletHolder( new FlashCrossDomainServlet() ), "" );

    return context;
}
 
Example 2
Source File: HttpBindManager.java    From Openfire with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a Jetty context handler that can be used to expose BOSH (HTTP-Bind) functionality.
 *
 * Note that an invocation of this method will not register the handler (and thus make the related functionality
 * available to the end user). Instead, the created handler is returned by this method, and will need to be
 * registered with the embedded Jetty webserver by the caller.
 *
 * @return A Jetty context handler (never null).
 */
protected Handler createBoshHandler()
{
    final int options;
    if(isHttpCompressionEnabled()) {
        options = ServletContextHandler.SESSIONS | ServletContextHandler.GZIP;
    } else {
        options = ServletContextHandler.SESSIONS;
    }
    final ServletContextHandler context = new ServletContextHandler( null, "/http-bind", options );

    // Ensure the JSP engine is initialized correctly (in order to be able to cope with Tomcat/Jasper precompiled JSPs).
    final List<ContainerInitializer> initializers = new ArrayList<>();
    initializers.add( new ContainerInitializer( new JasperInitializer(), null ) );
    context.setAttribute( "org.eclipse.jetty.containerInitializers", initializers );
    context.setAttribute( InstanceManager.class.getName(), new SimpleInstanceManager() );

    // Generic configuration of the context.
    context.setAllowNullPathInfo( true );

    // Add the functionality-providers.
    context.addServlet( new ServletHolder( new HttpBindServlet() ), "/*" );

    // Add compression filter when needed.
    if (isHttpCompressionEnabled()) {
        final GzipHandler gzipHandler = context.getGzipHandler();
        gzipHandler.addIncludedPaths("/*");
        gzipHandler.addIncludedMethods(HttpMethod.POST.asString());
    }

    return context;
}
 
Example 3
Source File: HttpBindManager.java    From Openfire with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a Jetty context handler that can be used to expose Websocket functionality.
 *
 * Note that an invocation of this method will not register the handler (and thus make the related functionality
 * available to the end user). Instead, the created handler is returned by this method, and will need to be
 * registered with the embedded Jetty webserver by the caller.
 *
 * @return A Jetty context handler (never null).
 */
protected Handler createWebsocketHandler()
{
    final ServletContextHandler context = new ServletContextHandler( null, "/ws", ServletContextHandler.SESSIONS );
    context.setAllowNullPathInfo(true);
    // Add the functionality-providers.
    context.addServlet( new ServletHolder( new OpenfireWebSocketServlet() ), "/*" );

    return context;
}