/** {@inheritDoc} */ @Override public void init(ServletConfig config) throws ServletException { super.init(config); Parameters.initialize(config.getServletContext()); if (!Parameter.LOG.getValueAsBoolean()) { // si log désactivé dans serveur de collecte, // alors pas de log, comme dans webapp LOGGER.setLevel(Level.WARN); } // dans le serveur de collecte, on est sûr que log4j est disponible LOGGER.info("initialization of the collector servlet of the monitoring"); httpAuth = new HttpAuth(); try { collectorServer = new CollectorServer(); } catch (final IOException e) { throw new ServletException(e.getMessage(), e); } }
@Override protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // add CORS headers for all HTTP responses (errors, etc.) if (boshManager.isCORSEnabled()) { if (boshManager.isAllOriginsAllowed()) { // Set the Access-Control-Allow-Origin header to * to allow all Origin to do the CORS response.setHeader("Access-Control-Allow-Origin", HttpBindManager.HTTP_BIND_CORS_ALLOW_ORIGIN_DEFAULT); } else { // Get the Origin header from the request and check if it is in the allowed Origin Map. // If it is allowed write it back to the Access-Control-Allow-Origin header of the respond. final String origin = request.getHeader("Origin"); if (boshManager.isThisOriginAllowed(origin)) { response.setHeader("Access-Control-Allow-Origin", origin); } } response.setHeader("Access-Control-Allow-Methods", HttpBindManager.HTTP_BIND_CORS_ALLOW_METHODS_DEFAULT); response.setHeader("Access-Control-Allow-Headers", HttpBindManager.HTTP_BIND_CORS_ALLOW_HEADERS_DEFAULT); response.setHeader("Access-Control-Max-Age", HttpBindManager.HTTP_BIND_CORS_MAX_AGE_DEFAULT); } super.service(request, response); }
@Override public void destroy() { executor.shutdownNow(); super.destroy(); } }
throws ServletException, IOException long lastModified = getLastModified(req); if (lastModified == -1) { doGet(req, resp); } else { long ifModifiedSince = req.getDateHeader(HEADER_IFMODSINCE); if (ifModifiedSince < (lastModified / 1000 * 1000)) { maybeSetLastModified(resp, lastModified); doGet(req, resp); } else { resp.setStatus(HttpServletResponse.SC_NOT_MODIFIED); long lastModified = getLastModified(req); maybeSetLastModified(resp, lastModified); doHead(req, resp); doPost(req, resp); doPut(req, resp); doDelete(req, resp); doOptions(req,resp); doTrace(req,resp);
@Override protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { logger.info("service('%s', '%s')", request, response); request.setCharacterEncoding(Constant.Charset.UTF8); response.setCharacterEncoding(Constant.Charset.UTF8); response.setContentType("text/html;charset=" + Constant.Charset.UTF8); super.service(request, response); session = request.getSession(); }
public boolean invoke(HttpServletRequest request, HttpServletResponse res, boolean returnErrors) throws ServletException { try { String pathInfo = request.getPathInfo() == null ? "" : request.getPathInfo(); AbstractHTTPDestination d = destinationRegistry.getDestinationForPath(pathInfo, true); if (!isHideServiceList && (request.getRequestURI().endsWith(serviceListRelativePath) || request.getRequestURI().endsWith(serviceListRelativePath + "/") || StringUtils.isEmpty(pathInfo) serviceListGenerator.service(request, res); } else { d = destinationRegistry.checkRestfulRequest(pathInfo); throw new ServletException(e);
@Override public void init(ServletConfig config) throws ServletException { super.init(config); wsFactory = WebSocketServletFactory.Loader.load(config.getServletContext(), wsPolicy); wsFactory.setCreator((req, resp) -> { ProxyWsClient proxyClient = (ProxyWsClient) req.getHttpServletRequest().getAttribute("teavm.ws.client"); if (proxyClient == null) { return new CodeWsEndpoint(this); wsFactory.start(); } catch (Exception e) { throw new ServletException(e);
@SuppressWarnings("unchecked") public void service(ServletRequest request, ServletResponse response) throws ServletException, IOException { HttpServletRequest httpRequest = (HttpServletRequest) request; Enumeration<String> names = (Enumeration<String>) httpRequest.getHeaderNames(); while (names.hasMoreElements()) { String name = names.nextElement(); String value = httpRequest.getHeader(name); OOZIE_HEADERS.put(name, value); } servlet.service(request, response); } }
@Override protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { log.debug("In service method for module servlet: " + request.getPathInfo()); String servletName = request.getPathInfo(); int end = servletName.indexOf("/", 1); response.setStatus(HttpServletResponse.SC_NOT_FOUND); return; servlet.service(request, response);
/** * {@inheritDoc} * * javax.http.servlet.HttpServlet does not let to override the code which deals with * unrecognized HTTP verbs such as PATCH (being standardized), WebDav ones, etc. * Thus we let CXF servlets process unrecognized HTTP verbs directly, otherwise we delegate * to HttpService */ @Override public void service(ServletRequest req, ServletResponse res) throws ServletException, IOException { HttpServletRequest request; HttpServletResponse response; try { request = (HttpServletRequest) req; response = (HttpServletResponse) res; } catch (ClassCastException e) { throw new ServletException("Unrecognized HTTP request or response object"); } String method = request.getMethod(); if (KNOWN_HTTP_VERBS.contains(method)) { super.service(request, response); } else { handleRequest(request, response); } }
@Override public void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String url = request.getRequestURI().replaceAll("^/go/rails/", "/go/"); servletHelper.getRequest(request).setRequestURI(url); rackServlet.service(request, response); }
response = (HttpServletResponse) res; } catch (ClassCastException e) { throw new ServletException("non-HTTP request or response"); service(request, response);
@Override protected void service(HttpServletRequest theReq, HttpServletResponse theResp) throws ServletException, IOException { theReq.setAttribute(REQUEST_START_TIME, new Date()); method = RequestTypeEnum.valueOf(theReq.getMethod()); } catch (IllegalArgumentException e) { super.service(theReq, theResp); return;
throws IOException, ServletException { String uri = request.getPathInfo(); response.sendError( HttpServletResponse.SC_NOT_FOUND, "Path information is not specified"); response.sendError( HttpServletResponse.SC_NOT_FOUND, "Path " + uri + " is invalid"); response.sendError( HttpServletResponse.SC_NOT_FOUND, "No servlet registred for context " + paths[1]); delegate.service(request, response);
@Override protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { Object old = req.getAttribute(RESPONSE_IN_REQUEST_ATTRIBUTE); try { req.setAttribute(RESPONSE_IN_REQUEST_ATTRIBUTE, resp); super.service(req, resp); } finally { req.setAttribute(RESPONSE_IN_REQUEST_ATTRIBUTE, old); } }
@Override public void init() throws ServletException { super.init(); // this.getServletContext().getAttribute("velocity"); }
@Override protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { if (!userIsSysadmin(request)) { response.sendError(HttpServletResponse.SC_UNAUTHORIZED, "Only system administrators can administrate Crucible"); return; } super.service(request, response); }
/** * Override service, adding the setup for legacy. */ protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, java.io.IOException { // parse the parameters of the request, considering Unicode issues, into a ParameterParser ParameterParser parser = new ParameterParser(req); // make this available from the req as an attribute req.setAttribute(ATTR_PARAMS, parser); // Setup.setup(req, resp); super.service(req, resp); }