ContextHandler contextHandler = new ContextHandler();
contextHandler.setContextPath( "" );
server.addHandler( contextHandler );
// Create a servlet container
ServletHandler servlets = new ServletHandler();
contextHandler.addHandler( servlets );
contextHandler.setAttribute( "queryEngine", queryEngine );
contextHandler.setAttribute( "collection", collection );
contextHandler.setAttribute( "titleList", titleList );
contextHandler.setAttribute( "action", "/Query" );
// TODO: very rudimentary: we should get the template from somewhere else instead...
contextHandler.setAttribute( "template", System.getProperty( "it.unimi.dsi.mg4j.query.QueryServlet.template" ) );
// Maps the main servlet onto the container.
servlets.addServletWithMapping( QueryServlet.class, "/Query" );
servlets.addServletWithMapping( HelpPage.class, "/Help" );
/* If an item servlet was specified, we link it to /Item. Otherwise,
* we inform the query servlet that it should generate direct URIs. */
if ( itemClass != null ) {
servlets.addServletWithMapping( itemClass, "/Item" );
if ( itemClass == FileSystemItem.class ) contextHandler.setAttribute( "derelativise", Boolean.TRUE );
}
else contextHandler.setAttribute( "uri", Boolean.TRUE );
contextHandler.setAttribute( "mimeType", itemMimeType );