private void loadJAXRSResource( String mountPoint, JaxRsServletHolderFactory jaxRsServletHolderFactory ) { SessionHandler sessionHandler = new SessionHandler(); sessionHandler.setServer( getJetty() ); log.debug( "Mounting servlet at [%s]", mountPoint ); ServletContextHandler jerseyContext = new ServletContextHandler(); jerseyContext.setServer( getJetty() ); jerseyContext.setErrorHandler( new NeoJettyErrorHandler() ); jerseyContext.setContextPath( mountPoint ); jerseyContext.setSessionHandler( sessionHandler ); jerseyContext.addServlet( jaxRsServletHolderFactory.create( defaultInjectables, wadlEnabled ), "/*" ); addFiltersTo( jerseyContext ); handlers.addHandler( jerseyContext ); }
mServletContextHandler.setErrorHandler(errorHandler); } catch (MalformedURLException e) { LOG.error("ERROR: resource path is malformed", e);
mServletContextHandler.setErrorHandler(errorHandler); } catch (MalformedURLException e) { LOG.error("ERROR: resource path is malformed", e);
public WebServer(Config config) { initServer(config); ServletContextHandler servletHandler = new ServletContextHandler(ServletContextHandler.SESSIONS); int sessionTimeout = config.getInteger("web.sessionTimeout"); if (sessionTimeout > 0) { servletHandler.getSessionHandler().setMaxInactiveInterval(sessionTimeout); } initApi(config, servletHandler); if (config.getBoolean("web.console")) { servletHandler.addServlet(new ServletHolder(new ConsoleServlet()), "/console/*"); } initWebApp(config, servletHandler); servletHandler.setErrorHandler(new ErrorHandler() { @Override protected void handleErrorPage( HttpServletRequest request, Writer writer, int code, String message) throws IOException { writer.write("<!DOCTYPE<html><head><title>Error</title></head><html><body>" + code + " - " + HttpStatus.getMessage(code) + "</body></html>"); } }); HandlerList handlers = new HandlerList(); initClientProxy(config, handlers); handlers.addHandler(servletHandler); server.setHandler(handlers); }
this.contextHandler.setErrorHandler(new SilentErrorHandler());
servletHandler.setErrorHandler(errorHandler);
servletContextHandler.setErrorHandler(createErrorHandler()); jettyServer.setHandler(servletContextHandler);
servletHandler.setErrorHandler(errorHandler);
/** * Run couchdb-lucene. */ public static void main(String[] args) throws Exception { final Config config = new Config(); final File dir = config.getDir(); final Server server = new Server(); final ServerConnector connector = new ServerConnector(server); connector.setHost(config.getConfiguration().getString("lucene.host", "localhost")); connector.setPort(config.getConfiguration().getInt("lucene.port", 5985)); LOG.info("Accepting connections with " + connector); server.addConnector(connector); server.setStopAtShutdown(true); final LuceneServlet servlet = new LuceneServlet(config.getClient(), dir, config.getConfiguration()); final ServletContextHandler context = new ServletContextHandler(server, "/", ServletContextHandler.NO_SESSIONS | ServletContextHandler.NO_SECURITY); context.addServlet(new ServletHolder(servlet), "/*"); context.setErrorHandler(new JSONErrorHandler()); context.setGzipHandler(new GzipHandler()); server.setHandler(context); server.start(); server.join(); }
servletHandler.setErrorHandler(errorHandler);
public AppContext() { contextHandler.setErrorHandler(errorHandler); }
@Bean public ServletContextHandler servletContextHandler(){ ServletContextHandler context = new ServletContextHandler(ServletContextHandler.NO_SESSIONS | ServletContextHandler.NO_SECURITY); context.setErrorHandler(null); context.setWelcomeFiles(new String[] { "/" }); return context; }
private ServletContextHandler createSoapContext(final HandlerCollection handlers, final String contextPath, final IncomingProbes probes, final boolean enablePublicStacktraces) { final ServletContextHandler soapContext_ = new ServletContextHandler(handlers, contextPath, ServletContextHandler.SESSIONS); soapContext_.setErrorHandler(new PetalsErrorHandler(enablePublicStacktraces, probes, this.logger)); return soapContext_; }
// Default error handler ErrorPageErrorHandler errorHandler = new ErrorPageErrorHandler(); errorHandler.addErrorPage(500,"/error"); // Your webapp ServletContextHandler context = new ServletContextHandler(); context.setErrorHandler(errorHandler); context.addServlet(MyCustomErrorServlet.class, "/error"); // etc ...
/** Build a ServletContextHandler. */ private ServletContextHandler buildServletContext(String contextPath) { if ( contextPath == null || contextPath.isEmpty() ) contextPath = "/"; else if ( !contextPath.startsWith("/") ) contextPath = "/" + contextPath; ServletContextHandler context = new ServletContextHandler(); context.setDisplayName(servletContextName); context.setErrorHandler(errorHandler); context.setContextPath(contextPath); if ( securityHandler != null ) context.setSecurityHandler(securityHandler); return context; }
/** Build a ServletContextHandler. */ private ServletContextHandler buildServletContext(String contextPath) { if ( contextPath == null || contextPath.isEmpty() ) contextPath = "/"; else if ( !contextPath.startsWith("/") ) contextPath = "/" + contextPath; ServletContextHandler context = new ServletContextHandler(); context.setDisplayName(servletContextName); context.setErrorHandler(errorHandler); context.setContextPath(contextPath); if ( securityHandler != null ) context.setSecurityHandler(securityHandler); return context; }
/** Build a ServletContextHandler. */ private ServletContextHandler buildServletContext(String contextPath) { if ( contextPath == null || contextPath.isEmpty() ) contextPath = "/"; else if ( !contextPath.startsWith("/") ) contextPath = "/" + contextPath; ServletContextHandler context = new ServletContextHandler(); context.setDisplayName(servletContextName); context.setErrorHandler(errorHandler); context.setContextPath(contextPath); if ( securityHandler != null ) context.setSecurityHandler(securityHandler); return context; }
private static ServletContextHandler getServletContextHandler(WebApplicationContext context) throws IOException { ServletContextHandler contextHandler = new ServletContextHandler(); contextHandler.setErrorHandler(null); contextHandler.setContextPath(CONTEXT_PATH); contextHandler.addServlet(new ServletHolder(new DispatcherServlet(context)), MAPPING_URL); contextHandler.addEventListener(new ContextLoaderListener(context)); contextHandler.setResourceBase(new ClassPathResource("webapp").getURI().toString()); return contextHandler; }
ServletContextHandler servletContextHandler = new ServletContextHandler(server, "/", ServletContextHandler.SESSIONS); servletContextHandler.setContextPath("/"); servletContextHandler.setWelcomeFiles(new String[] { "index.html" }); servletContextHandler.setResourceBase(webDir); servletContextHandler.addServlet(DefaultServlet.class, "/"); ErrorPageErrorHandler errorHandler = new ErrorPageErrorHandler(); errorHandler.addErrorPage(404, "/"); // return root ... being index.html servletContextHandler.setErrorHandler(errorHandler);
URL urlToWebDir = findUrlTo("/web"); ServletContextHandler servletContextHandler = new ServletContextHandler(server, "/", ServletContextHandler.SESSIONS); servletContextHandler.setContextPath("/"); servletContextHandler.setWelcomeFiles(new String[] { "index.html" }); servletContextHandler.setBaseResource(Resource.newResource(urlToWebDir)); servletContextHandler.addServlet(DefaultServlet.class, "/"); ErrorPageErrorHandler errorMapper = new ErrorPageErrorHandler(); errorMapper.addErrorPage(404,"/"); // map all 404's to root (aka /index.html) servletContextHandler.setErrorHandler(errorMapper);