Processes requests for both HTTP <code>GET</code> and <code>POST</code>
methods.

@param request servlet request
@param response servlet response
@throws ServletException if a servlet-specific error occurs
@throws IOException if an I/O error occurs
355372
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        response.setContentType("text/html;charset=UTF-8");
        if (!request.getServletPath().endsWith("insecure")) {
            response.addHeader("Content-Security-Policy", buildCSPHeader());
        }
        request.getRequestDispatcher("WEB-INF/chatq.jspx").forward(request, response);
    }
86809
private void processInternal( HttpServletRequest request, HttpServletResponse response )
            throws IOException, ServletException
    {
        //
        // First wrap the request with an object that contains request-scoped values that our runtime uses.  This
        // is faster than sticking everything into attributes on the request (then basically reading from a HashMap).
        //
        request = PageFlowRequestWrapper.wrapRequest( request );

        String uri = InternalUtils.getDecodedServletPath( request );
        ServletContext servletContext = getServletContext();

        // The ServletContainerAdapter reference may have been lost during serialization/deserialization.
        if (_servletContainerAdapter == null) {
            _servletContainerAdapter = AdapterManager.getServletContainerAdapter( servletContext );
        }

        //
        // Allow the container to do a security check on forwarded requests, if that feature is enabled.
        //
        if ( LegacySettings.get( servletContext ).shouldDoSecureForwards()
             && PageFlowRequestWrapper.get( request ).isForwardedRequest() )
        {
            //
            // In some situations (namely, in scoped requests under portal), the initial
            // security check may not have been done for the request URI.  In this case, a redirect
            // to https may happen during checkSecurity().
            //
            if ( _servletContainerAdapter.doSecurityRedirect( uri, request, response ) )
            {
                if ( LOG.isDebugEnabled() )
                    LOG.debug( "checkSecurity() caused a redirect.  Ending processing for this request "
                               + '(' + uri + ')' );

                return;
            }
        }

        //
        // If we've come in on a forced redirect due to security constraints, look for request attrs
        // that we put into the session.
        //
        String hash = request.getParameter( REDIRECT_REQUEST_ATTRS_PARAM );
        if ( hash != null )
        {
            HttpSession session = request.getSession( false );

            if ( session != null )
            {
                String carryoverAttrName = makeRedirectedRequestAttrsKey( uri, hash );
                Map attrs = ( Map ) session.getAttribute( carryoverAttrName );
                session.removeAttribute( carryoverAttrName );

                if ( attrs != null )
                {
                    for ( Iterator i = attrs.entrySet().iterator(); i.hasNext(); )
                    {
                        Map.Entry entry = ( Map.Entry ) i.next();

                        String attrName = ( String ) entry.getKey();
                        if ( request.getAttribute( attrName ) == null )
                        {
                            request.setAttribute( attrName, entry.getValue() );
                        }
                    }
                }
            }
        }

        //
        // The requested action can be overridden by a request parameter.  In this case, we parse the action from
        // the request parameter and forward to a URI constructed from it.  If this happens, just return.
        //
        if ( processActionOverride( request, response ) ) return;

        //
        // Process any direct request for a page flow by forwarding to its "begin" action.
        //
        if ( processPageFlowRequest( request, response, uri ) ) return;

        //
        // Get the FlowController for this request (page flow or shared flow), and cache it in the request.
        //
        String flowControllerClassName = InternalUtils.getFlowControllerClassName( moduleConfig );

        if ( flowControllerClassName == null &&
             ! ( moduleConfig instanceof AutoRegisterActionServlet.MissingRootModuleControllerConfig ) )
        {
            //
            // If this isn't a blank module initialized in place of a missing root PageFlowController, emit a warning
            // about the missing controllerClass property.
            //
            if(LOG.isWarnEnabled())
                LOG.warn( "Struts module " + moduleConfig.getPrefix() + " is configured to use " + getClass().getName()
                    + " as the request processor, but the <controller> element does not contain a <set-property>"
                    + " for \"controllerClass\".  Page Flow actions in this module may not be handled correctly." );
        }

        //
        // Look up or create the appropriate SharedFlowControllers if they don't exist.
        //
        if ( LOG.isInfoEnabled() )
            LOG.info( "Attempting to instantiate SharedFlowControllers for request " + request.getRequestURI() );

        FlowController currentFlowController = null;

        try
        {
            RequestContext requestContext = new RequestContext( request, response );
            Map/*< String, SharedFlowController >*/ sharedFlows =
                    _flowControllerFactory.getSharedFlowsForRequest( requestContext );

            /* todo: why are the shared flow / global app objects loaded for data binding here? */
            ImplicitObjectUtil.loadSharedFlow( request, sharedFlows );
            ImplicitObjectUtil.loadGlobalApp( request, PageFlowUtils.getGlobalApp( request ) );

            if ( flowControllerClassName != null )
            {
                currentFlowController = getFlowController( requestContext, flowControllerClassName );
                PageFlowRequestWrapper.get( request ).setCurrentFlowController( currentFlowController );
            }
            else
            {
                PageFlowRequestWrapper.get( request ).setCurrentFlowController( null );
            }
        }
        catch ( ClassNotFoundException e )
        {
            LOG.error( "Could not find FlowController class " + flowControllerClassName, e );
            ServletUtils.throwServletException(e);
        }
        catch ( InstantiationException e )
        {
            LOG.error( "Could not instantiate FlowController of type " + flowControllerClassName, e );
            ServletUtils.throwServletException(e);
        }
        catch ( IllegalAccessException e )
        {
            LOG.error( "Could not instantiate FlowController of type " + flowControllerClassName, e );
            ServletUtils.throwServletException(e);
        }

        //
        // Get the page flow for this request.
        //
        PageFlowController jpf = PageFlowUtils.getCurrentPageFlow( request, getServletContext() );

        //
        // Remove any current JavaServer Faces backing bean.  We have "left" any JSF page and are now processing a
        // Page Flow action.
        //
        InternalUtils.removeCurrentFacesBackingBean( request, servletContext );

        //
        // Set up implicit objects used by the expression language in simple actions and in declarative validation.
        //
        ImplicitObjectUtil.loadImplicitObjects( request, response, servletContext, jpf );

        try
        {
            super.process( request, response );
        }
        catch ( UnhandledException unhandledException )
        {
            // If we get here, then we've already tried to find an exception handler.  Just throw.
            rethrowUnhandledException( unhandledException );
        }
        catch ( ServletException servletEx )
        {
            // If a ServletException escapes out of any of the processing methods, let the current FlowController handle it.
            if ( ! handleException( servletEx, currentFlowController, request, response ) )
                throw servletEx;
        }
        catch ( IOException ioe )
        {
            // If an IOException escapes out of any of the processing methods, let the current FlowController handle it.
            if ( ! handleException( ioe, currentFlowController, request, response ) )
                throw ioe;
        }
        catch ( Throwable th )
        {
            // If a Throwable escapes out of any of the processing methods, let the current FlowController handle it.
            if ( ! handleException( th, currentFlowController, request, response ) )
            {
                if ( th instanceof Error )
                    throw ( Error ) th;
                ServletUtils.throwServletException(th);
            }
        }
    }
188773
private void invokeOpByName(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException
   {
      String name = request.getParameter("name");

      if (trace)
         log.trace("invokeOpByName, name=" + name);

      String[] argTypes = request.getParameterValues("argType");
      String[] args = getArgs(request);
      String methodName = request.getParameter("methodName");

      if (methodName == null)
         throw new ServletException("No methodName given in invokeOpByName form");

      try
      {
         OpResultInfo opResult = invokeOpByName(name, methodName, argTypes, args);
         request.setAttribute("opResultInfo", opResult);

         RequestDispatcher rd = this.getServletContext().getRequestDispatcher("/displayopresult.jsp");
         rd.forward(request, response);
      }
      catch (Exception e)
      {
         throw new ServletException("Failed to invoke operation", e);
      }
   }
1144986
public void handleGet(HttpRequest request, HttpResponse response) throws HttpException, IOException {
        String uri = request.getRequestLine().getUri();
        LOG.debug("uri {}", uri);
        try {
            ResponseUpdater ru = this.findResponseUpdater(request);
            LOG.debug("request updater {}", ru);
            ru.update(response);
        } catch (IllegalStateException t) {
            LOG.error("Cannot handle request", t);
            throw new HttpException("Cannot handle request", t);
        }
    }
246297
@Override
	protected void doGet(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		long start = System.nanoTime();
		ProcessRetrieveResponse responseObject = ProcessRetrieveRequest.checkRequestParameter(request,
				this.getServletContext());
		String resultJson = responseObject.buildJsonResonse();
		response.setContentType("application/json"); 
		PrintWriter out = response.getWriter();
		long end = System.nanoTime();
		//+ " " + (end - start)/1000 + " micro seconds"
		out.println(resultJson);
		out.flush();
	}
1322690
public void doGet(HttpServletRequest request,
                      HttpServletResponse response) 
        throws ServletException, IOException
    {
        if (request.getQueryString()!=null &&
            request.getQueryString().length()>0)
        {
            String target=doAction(request);
            response.sendRedirect(request.getContextPath()+
                                  request.getServletPath()+
                                  (request.getPathInfo()!=null
                                   ?request.getPathInfo():"")+
                                  (target!=null?("#"+target):""));
            return;
        }
        
        Page page= new Page();
        page.title(getServletInfo());
        page.addHeader("");
        page.attribute("text","#000000");
        page.attribute(Page.BGCOLOR,"#FFFFFF");
        page.attribute("link","#606CC0");
        page.attribute("vlink","#606CC0");
        page.attribute("alink","#606CC0");

        page.add(new Block(Block.Bold).add(new Font(3,true).add(getServletInfo())));
        page.add(Break.rule);
        Form form=new Form(request.getContextPath()+
                           request.getServletPath()+
                           "?A=exit");
        form.method("GET");
        form.add(new Input(Input.Submit,"A","Exit All Servers"));
        page.add(form);
        page.add(Break.rule);
        page.add(new Heading(3,"Components:"));

        List sList=new List(List.Ordered);
        page.add(sList);
        
        String id1;
        int i1=0;
        Iterator s=_servers.iterator();
        while(s.hasNext())
        {
            id1=""+i1++;
            HttpServer server=(HttpServer)s.next();            
            Composite sItem = sList.newItem();
            sItem.add("<B>HttpServer&nbsp;");
            sItem.add(lifeCycle(request,id1,server));
            sItem.add("</B>");
            sItem.add(Break.line);
            sItem.add("<B>Listeners:</B>");
            List lList=new List(List.Unordered);
            sItem.add(lList);

            HttpListener[] listeners=server.getListeners();
            for (int i2=0;i2<listeners.length;i2++)
            {
                HttpListener listener = listeners[i2];
                String id2=id1+":"+listener;
                lList.add(lifeCycle(request,id2,listener));
            }

            Map hostMap = server.getHostMap();
            
            sItem.add("<B>Contexts:</B>");
            List hcList=new List(List.Unordered);
            sItem.add(hcList);
            Iterator i2=hostMap.entrySet().iterator();
            while(i2.hasNext())
            {
                Map.Entry hEntry=(Map.Entry)(i2.next());
                String host=(String)hEntry.getKey();

                PathMap contexts=(PathMap)hEntry.getValue();
                Iterator i3=contexts.entrySet().iterator();
                while(i3.hasNext())
                {
                    Map.Entry cEntry=(Map.Entry)(i3.next());
                    String contextPath=(String)cEntry.getKey();
                    java.util.List contextList=(java.util.List)cEntry.getValue();
                    
                    Composite hcItem = hcList.newItem();
                    if (host!=null)
                        hcItem.add("Host="+host+":");
                    hcItem.add("ContextPath="+contextPath);
                    
                    String id3=id1+":"+host+":"+
                        (contextPath.length()>2
                         ?contextPath.substring(0,contextPath.length()-2)
                         :contextPath);
                    
                    List cList=new List(List.Ordered);
                    hcItem.add(cList);
                    for (int i4=0;i4<contextList.size();i4++)
                    {
                        String id4=id3+":"+i4;
                        Composite cItem = cList.newItem();
                        HttpContext hc=
                            (HttpContext)contextList.get(i4);
                        cItem.add(lifeCycle(request,id4,hc));
                        cItem.add("<BR>ResourceBase="+hc.getResourceBase());
                        cItem.add("<BR>ClassPath="+hc.getClassPath());

                    
                        List hList=new List(List.Ordered);
                        cItem.add(hList);
                        int handlers = hc.getHandlers().length;
                        for(int i5=0;i5<handlers;i5++)
                        {
                            String id5=id4+":"+i5;
                            HttpHandler handler = hc.getHandlers()[i5];
                            Composite hItem=hList.newItem();
                            hItem.add(lifeCycle(request,
                                                id5,
                                                handler,
                                                handler.getName()));
                            if (handler instanceof ServletHandler)
                            {
                                hItem.add("<BR>"+
                                          ((ServletHandler)handler)
                                          .getServletMap());
                            }
                        }
                    }
                }
            }
            sItem.add("<P>");
        }


        response.setContentType("text/html");
        response.setHeader("Pragma", "no-cache");
        response.setHeader("Cache-Control", "no-cache,no-store");
        Writer writer=response.getWriter();
        page.write(writer);
        writer.flush();
    }
541279
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String tech = request.getParameter(PARAMETER_TECH);
        String workspaceId = request.getParameter(PARAMETER_WORKSPACE);    //specify the unique workspace directory to upload the file(s) to.    
        Collection<Part> filePartCollection = request.getParts();
        
        String serverHostPort = request.getRequestURL().toString().replace(request.getRequestURI(), "");
        int schemeLength = request.getScheme().toString().length();
        String internalHostPort = "http" + serverHostPort.substring(schemeLength);
        log.log(Level.FINER, "serverHostPort : " + serverHostPort);
        final ServiceConnector serviceConnector = new ServiceConnector(serverHostPort, internalHostPort);
        HashMap<Part, String> fileNames = new HashMap<Part, String>();
        if(!isValidRequest(request, response, tech, workspaceId, filePartCollection, serviceConnector, fileNames)){
            return;
        }

        Service techService = serviceConnector.getServiceObjectFromId(tech);
        String techDirPath = StarterUtil.getWorkspaceDir(workspaceId) + "/" + techService.getId();
        File techDir = new File(techDirPath);
        if(techDir.exists() && techDir.isDirectory() && "true".equalsIgnoreCase(request.getParameter(PARAMETER_CLEANUP))){
            FileUtils.cleanDirectory(techDir);
            log.log(Level.FINER, "Cleaned up tech workspace directory : " + techDirPath);
        }

        for (Part filePart : filePartCollection){
            if(!techDir.exists()){
                FileUtils.forceMkdir(techDir);
                log.log(Level.FINER, "Created tech directory :" + techDirPath);
            }
            
            String filePath = techDirPath + "/" + fileNames.get(filePart);
            log.log(Level.FINER, "File path : " + filePath);
            File uploadedFile = new File(filePath);

            Files.copy(filePart.getInputStream(), uploadedFile.toPath(), StandardCopyOption.REPLACE_EXISTING);
            log.log(Level.FINE, "Copied file to " + filePath);    
        }

        if("true".equalsIgnoreCase(request.getParameter(PARAMETER_PROCESS))){
            // Process uploaded file(s)
            String processResult = serviceConnector.processUploadedFiles(techService, techDirPath);
            if(!processResult.equalsIgnoreCase("success")){
                log.log(Level.INFO, "Error processing the files uploaded to " + techDirPath + " : Result=" + processResult);
                response.sendError(500, processResult);
                return;
            }
            log.log(Level.FINE, "Processed the files uploaded to " + techDirPath);    
        }

        response.setContentType("text/html");
        PrintWriter out = response.getWriter();
        out.println("success");
        out.close();
    }
1242475
@Override
  protected void doPost(final HttpServletRequest req, final HttpServletResponse resp)
      throws ServletException, IOException {
    final Map<String, Object> ret = new HashMap<>();

    if (hasParam(req, ACTION_PARAM)) {
      final String action = getParam(req, ACTION_PARAM);
      if (action.equals(STATS_SET_REPORTINGINTERVAL)) {
        handleChangeMetricInterval(req, ret);
      } else if (action.equals(STATS_SET_CLEANINGINTERVAL)) {
        handleChangeCleaningInterval(req, ret);
      } else if (action.equals(STATS_SET_MAXREPORTERPOINTS)) {
        handleChangeEmitterPoints(req, ret);
      } else if (action.equals(STATS_GET_ALLMETRICSNAME)) {
        handleGetAllMMetricsName(req, ret);
      } else if (action.equals(STATS_GET_METRICHISTORY)) {
        handleGetMetricHistory(req, ret);
      } else if (action.equals(STATS_SET_ENABLEMETRICS)) {
        handleChangeManagerStatusRequest(req, ret, true);
      } else if (action.equals(STATS_SET_DISABLEMETRICS)) {
        handleChangeManagerStatusRequest(req, ret, false);
      } else {
        ret.put(RESPONSE_ERROR, "Invalid action");
      }
    }

    JSONUtils.toJSON(ret, resp.getOutputStream(), true);
  }
990954
@Override
    public void doPost(HttpServletRequest httpRequest, HttpServletResponse httpResponse)
            throws ServletException, IOException {
        CallFuture<NaviRpcResponse> callFuture = new CallFuture<NaviRpcResponse>();
        try {
            NaviRpcExporter serviceExporter = getRpcExporter(httpRequest);
            String protocol = getProtocolByHttpContentType(httpRequest);
            LocalContext.getContext().setStartTime().setProtocol(protocol)
                    .setFromIp(IPUtils.getIpAddr(httpRequest))
                    .setServiceName(serviceExporter.getName());

            byte[] byteArray = ByteUtil.readStream(httpRequest.getInputStream(),
                    httpRequest.getContentLength());
            LocalContext.getContext().setReqByteSize(byteArray.length);

            NaviRpcRequest request = new NaviRpcRequest(serviceExporter, byteArray);
            processor.service(request, callFuture);
        } catch (InvalidRequestException e) {
            callFuture.cancel(true);
            LOG.warn(e.getMessage());
            httpResponse.setStatus(HttpStatus.SC_BAD_REQUEST);
        } catch (InvalidProtocolException e) {
            callFuture.cancel(true);
            LOG.warn(e.getMessage());
            httpResponse.setStatus(HttpStatus.SC_NOT_ACCEPTABLE);
        } catch (ServiceNotFoundException e) {
            callFuture.cancel(true);
            LOG.warn(e.getMessage());
            httpResponse.setStatus(HttpStatus.SC_NOT_FOUND);
        } catch (CodecException e) {
            callFuture.cancel(true);
            LOG.warn(e.getMessage());
            httpResponse.setStatus(HttpStatus.SC_BAD_REQUEST);
            callFuture.cancel(true);
        } catch (DeserilizeNullException e) {
            callFuture.cancel(true);
            LOG.warn(e.getMessage());
            httpResponse.setStatus(HttpStatus.SC_BAD_REQUEST);
        } catch (MethodNotFoundException e) {
            callFuture.cancel(true);
            LOG.warn(e.getMessage());
            httpResponse.setStatus(HttpStatus.SC_NOT_FOUND);
        } catch (ServerErrorException e) {
            callFuture.cancel(true);
            LOG.warn(e.getMessage());
            httpResponse.setStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR);
        } catch (Exception e) {
            callFuture.cancel(true);
            LOG.error(e.getMessage(), e);
            httpResponse.setStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR);
        } finally {
            try {
                buildHttpResponse(httpResponse, callFuture.get(), httpRequest.getContentType(),
                        httpRequest.getCharacterEncoding());
            } catch (InterruptedException e2) {
                LOG.error(e2.getMessage(), e2);
            }
            LocalContext.removeContext();
        }
    }
1343180
public boolean checkGet(HttpServletRequest request, HttpServletResponse response)
            throws IOException, ServletException {
        if (!request.getMethod().equals("GET")) {
            response.sendError(405);  // 405 - Incorrect method.
            return false;
        }

        return true;
    }
1316471
public void service(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
		//Creates the output stream.
		PrintWriter out = response.getWriter();
		response.setContentType("text/html");

		//Creates the HTML file with the appropriate tags
		out.println("<HTML><HEAD><TITLE>Snoop Servlet</TITLE></HEAD>");
		//Sets background to white
		out.println("<BODY BGColor = \"white\">");
		//Prints the url, using the request object.
		out.println("<H1>URL</H1>");
		out.println("http://" + request.getServerName() + ':' + request.getServerPort() + request.getRequestURI() + "<BR><BR>");
		out.println("Request Protocol: " + request.getProtocol() + "<BR>");

		out.println("<H1>Servlet Init Variables:</H1>");
		Enumeration e = getServletConfig().getInitParameterNames();
		while (e.hasMoreElements()) {
			Object o = e.nextElement();
			out.println(String.valueOf(o) + " = " + getServletConfig().getInitParameter((String) o) + "<BR>");
		}
		out.println("<BR><BR>");

		//Prints out HTTP variables, each one is self explanitory.
		//Uses the request object to get the information.
		out.println("<H1>HTTP Header Variables:</H1>");
		out.println("Request Protocol: " + request.getProtocol() + "<BR>");
		out.println("Request Method: " + request.getMethod() + "<BR>");
		out.println("Remote Host: " + request.getRemoteHost() + "<BR>");
		out.println("Remote User: " + request.getRemoteUser() + "<BR>");
		out.println("Remote Address: " + request.getRemoteAddr() + "<BR>");
		out.println("Content Type: " + request.getContentType() + "<BR>");
		out.println("Content Length: " + request.getContentLength() + "<BR>");
		out.println("Query String: " + request.getQueryString() + "<BR>");
		out.println("Server Name: " + request.getServerName() + "<BR>");
		out.println("Server Port: " + request.getServerPort() + "<BR>");
		out.println("Request URI: " + request.getRequestURI() + "<BR>");
		out.println("Servlet Path: " + request.getServletPath() + "<BR><BR>");
		out.println("<H1>User Supplied Parameters:</H1>");

		printParameters(request, out);

		out.println("<H1>Headers:</H1>");
		e = request.getHeaderNames();
		while (e.hasMoreElements()) {
			String key = (String) e.nextElement();
			String value = request.getHeader(key);
			out.print(' ' + key + " = ");
			out.print(value + "<BR>");
		}

		out.println("<BR><BR>");

		//Prints out HTTP variables, each one is self explanitory.
		//Uses the request object to get the information.
		out.println("<H1>Servlet Context attributes:</H1>");

		e = getServletContext().getAttributeNames();
		while (e.hasMoreElements()) {
			Object o = e.nextElement();
			out.println(String.valueOf(o) + " = " + getServletContext().getAttribute((String) o) + "<BR>");
		}

		out.println("<BR><BR>");

		//Prints out HTTP variables, each one is self explanitory.
		//Uses the request object to get the information.
		out.println("<H1>Servlet Context init parameters:</H1>");

		e = getServletContext().getInitParameterNames();
		while (e.hasMoreElements()) {
			Object o = e.nextElement();
			out.println(String.valueOf(o) + " = " + getServletContext().getInitParameter((String) o) + "<BR>");
		}

	}
912192
protected void doRequest (HttpServletRequest request, HttpServletResponse response)
         throws ServletException, IOException
    {
        InvocationContext context = null;
        try {
            context =  new InvocationContext(request, response);
            setContentType(request, response);

            Template template = handleRequest(request, response, context);
            if (template != null) {
                mergeTemplate(template, context);
            }

        } catch (Exception e) {
            log.warning("doRequest failed", "uri", request.getRequestURI(), e);
            response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e.getMessage());
        }
    }
284564
protected void process( HttpServletRequest request, HttpServletResponse response )
        throws IOException, ServletException
    {
        //
        // First wrap the request with an object that contains request-scoped values that our runtime uses.  This
        // is faster than sticking everything into attributes on the request (then basically reading from a HashMap).
        //
        PageFlowRequestWrapper requestWrapper = PageFlowRequestWrapper.wrapRequest( request );
        request = requestWrapper;
        
        ServletContext servletContext = getServletContext();
        String modulePath = PageFlowUtils.getModulePathForRelativeURI( InternalUtils.getDecodedServletPath( request ) );
        ModuleConfig registeredApp;
        
        //
        // Get the registered Struts module for the request.
        //
        registeredApp = getModuleConfig( modulePath, request, response );
        
        //
        // If we've dynamically registered a module, then we need to override the base process() behavior to select the
        // module.  Note that we don't want to synchronize the call to process().
        //
        if ( registeredApp != null )
        {
            //
            // Try to select the appropriate Struts module and delegate to its RequestProcessor.
            //
            ModuleConfig moduleConfig = InternalUtils.selectModule( modulePath, request, servletContext );
            
            // If this module came from an abstract page flow controller class, send an error.
            ControllerConfig cc = moduleConfig.getControllerConfig();
            if (cc instanceof PageFlowControllerConfig && ((PageFlowControllerConfig) cc).isAbstract()) {
                InternalUtils.sendDevTimeError( "PageFlow_AbstractPageFlow", null, HttpServletResponse.SC_NOT_FOUND, 
                                                request, response, servletContext,
                                                new Object[]{ modulePath } );
                return;
            }
                    
            RequestProcessor requestProcessor = getRequestProcessor( moduleConfig );
            requestProcessor.process( request, response );
        }
        else
        {
            //
            // Here, we're checking to see if this was a module that was registered externally by Struts (not by this
            // servlet).  This is the same as the base process() behavior, but it checks for a missing
            // module-configuration.
            //
            ModuleConfig moduleConfig = null;
            
            if ( InternalUtils.getModuleConfig( RequestUtils.getModuleName( request, servletContext ), servletContext ) != null )
            {
                String modulePrefix = RequestUtils.getModuleName( request, servletContext );
                moduleConfig = InternalUtils.selectModule( modulePrefix, request, servletContext );
            }
            
            String servletPath = InternalUtils.getDecodedServletPath( request );
            RequestProcessor rp = moduleConfig != null ? getRequestProcessor( moduleConfig ) : null;
            
            if ( rp != null && moduleCanHandlePath( moduleConfig, rp, servletPath ) )
            {
                rp.process( request, response );
            }
            else
            {
                //
                // Initialize the ServletContext in the request.  Often, we need access to the ServletContext when we only
                // have a ServletRequest.
                //
                InternalUtils.setServletContext( request, getServletContext() );
                
                if ( processUnhandledAction( request, response, servletPath ) ) return;
                
                String originalServletPath = requestWrapper.getOriginalServletPath();
                if ( originalServletPath != null )
                {
                    servletPath = originalServletPath;
                    modulePath = PageFlowUtils.getModulePathForRelativeURI( originalServletPath );
                }
                
                if ( _log.isErrorEnabled() )
                {
                    InternalStringBuilder msg = new InternalStringBuilder( "No module configuration registered for " );
                    msg.append( servletPath ).append( " (module path " ).append( modulePath ).append( ")." );
                    _log.error( msg.toString() );
                }

                //
                // If we're not in production mode, send a diagnostic on the response; otherwise, simply send a 404.
                //
                if ( modulePath.length() == 0 ) modulePath = "/";
                InternalUtils.sendDevTimeError( "PageFlow_NoModuleConf", null, HttpServletResponse.SC_NOT_FOUND, 
                                                request, response, servletContext,
                                                new Object[]{ servletPath, modulePath } );
            }
        }
    }
639771
public void service(HttpServletRequest request, HttpServletResponse response) throws IOException {

        // Get the script path from the request - include aware (GROOVY-815)
        final String scriptUri = getScriptUri(request);

        // Set it to HTML by default
        response.setContentType("text/html; charset="+encoding);

        // Set up the script context
        final ServletBinding binding = new ServletBinding(request, response, servletContext);
        setVariables(binding);

        // Run the script
        try {
            Closure closure = new Closure(gse) {

                public Object call() {
                    try {
                        return ((GroovyScriptEngine) getDelegate()).run(scriptUri, binding);
                    } catch (ResourceException | ScriptException e) {
                        throw new RuntimeException(e);
                    }
                }

            };
            GroovyCategorySupport.use(ServletCategory.class, closure);
        } catch (RuntimeException runtimeException) {
            StringBuilder error = new StringBuilder("GroovyServlet Error: ");
            error.append(" script: '");
            error.append(scriptUri);
            error.append("': ");
            Throwable e = runtimeException.getCause();
            /*
             * Null cause?!
             */
            if (e == null) {
                error.append(" Script processing failed.\n");
                error.append(runtimeException.getMessage());
                if (runtimeException.getStackTrace().length > 0)
                    error.append(runtimeException.getStackTrace()[0].toString());
                servletContext.log(error.toString());
                System.err.println(error.toString());
                runtimeException.printStackTrace(System.err);
                response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, error.toString());
                return;
            }
            /*
             * Resource not found.
             */
            if (e instanceof ResourceException) {
                error.append(" Script not found, sending 404.");
                servletContext.log(error.toString());
                System.err.println(error.toString());
                response.sendError(HttpServletResponse.SC_NOT_FOUND);
                return;
            }
            /*
             * Other internal error. Perhaps syntax?!
             */
            servletContext.log("An error occurred processing the request", runtimeException);
            error.append(e.getMessage());
            if (e.getStackTrace().length > 0)
                error.append(e.getStackTrace()[0].toString());
            servletContext.log(e.toString());
            System.err.println(e.toString());
            runtimeException.printStackTrace(System.err);
            response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e.toString());
        }
    }
227543
@Override
    public void doGet(HttpServletRequest request,
            HttpServletResponse response)
            throws IOException, ServletException {
        super.doGet(request, response);
        String target = request.getPathInfo();
        if (target == null) target = "/";
        try {
            unauthenticate(request);
            response.setContentType(HTML_CONTENT_TYPE);
            response.sendRedirect("/");
        } catch (Exception ex) {
            rateLimitedLogWarn("Not servicing url: %s Details: ", target, ex.getMessage());
            response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
            response.getWriter().print(buildClientResponse(null, ClientResponse.UNEXPECTED_FAILURE, Throwables.getStackTraceAsString(ex)));
        }
    }
1012556
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
            log.severe("Binary content has been requested");
        
        String repository = request.getParameter("repository");
        String workspace = request.getParameter("workspace");
        String path = request.getParameter("path");
        String property = request.getParameter("property");

        Connector connector = (Connector) request.getSession().getAttribute("connector");
        try {
            Session session = connector.find(repository).session(workspace);
            Node node = session.getNode(path);

            Property p;
            try {
                p = node.getProperty(property);
            } catch (PathNotFoundException e) {
                response.setContentType("text/html");
                PrintWriter writer = response.getWriter();
                writer.write("<html>");
                writer.write("<p>Content not found or recently removed</p>");
                writer.write("</html>");
                return;
            }
            
            Binary binary = p.getBinary();


            InputStream in = binary.getStream();
            String contentType = node.getProperty("jcr:mimeType").getString();

            response.setContentType(contentType);

            int b;
            while ((b = in.read()) != -1) {
                response.getOutputStream().write(b);
            }

            log.severe("Sent binary content");
            binary.dispose();

        } catch (Exception e) {
            throw new ServletException(e);
        }
    }
516212
@Override
    public void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        Context context =
                ReadOnlyContext.getContext(Constants.HTTP_REQUEST.REST.uri,
                                           request);
        try {
            // Create a new file upload handler
            ServletFileUpload upload = new ServletFileUpload();

            // Parse the request, looking for "file"
            InputStream in = null;
            FileItemIterator iter = upload.getItemIterator(request);
            while (in == null && iter.hasNext()) {
                FileItemStream item = iter.next();
                logger.info("Got next item: isFormField={} fieldName={}", item.isFormField(), item.getFieldName());
                if (!item.isFormField() && item.getFieldName().equals("file")) {
                    in = item.openStream();
                }
            }
            if (in == null) {
                sendResponse(HttpServletResponse.SC_BAD_REQUEST,
                             "No data sent.",
                             response);
            } else {
                sendResponse(HttpServletResponse.SC_CREATED,
                             m_management.putTempStream(context, in),
                             response);
            }
        } catch (AuthzException ae) {
            throw RootException.getServletException(ae,
                                                    request,
                                                    "Upload",
                                                    EMPTY_STRING_ARRAY);
        } catch (Exception e) {
            e.printStackTrace();
            sendResponse(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e
                    .getClass().getName()
                    + ": " + e.getMessage(), response);
        }
    }