Package org.apache.tomcat.core

Examples of org.apache.tomcat.core.Response


  Ajp14Request req=null;
  if( thData != null ) {
      req=(Ajp14Request)thData[0];
  }
  if( req != null ) {
      Response res=req.getResponse();
      req.recycle();
      res.recycle();
      // make the note available to other modules
      req.setNote( ajp14_note, req.ajp13);
      return req;
  }
  // either thData==null or broken ( req==null)
View Full Code Here


  }
  return wrapper;
    }

    private void doPreCompileService(Request req) {
  Response res = req.getResponse();
  if( res == null || res.getBuffer() == null){
      return; // A load-on-startup Request
  }
  try {
      res.setContentType("text/html")

      String msg="<h1>Jsp Precompile Done</h1>";
     
      res.setContentLength(msg.length());

      res.getBuffer().write( msg );
  } catch(IOException iex) {
      log("Pre-compile error",iex);
  }
    }
View Full Code Here

  /** We need to find the request/response. The servlet API
   *  guarantees that we will receive the original request as parameter.
   */
  Request realRequest = ((HttpServletRequestFacade)request).
      getRealRequest();
        Response realResponse = realRequest.getResponse();

  // according to specs (as of 2.2: started is OK, just not committed)
  if (realResponse.isBufferCommitted())
      throw new IllegalStateException(sm.getString("rdi.forward.ise"));

  // reset the output buffer but not the headers and cookies
  realResponse.resetBuffer();

  // the strange case in a separate method.
  if( name!=null) {
      forwardNamed( request, response );
      return;
  }
 
  // from strange spec reasons, forward and include are very different in
  // the way they process the request - if you don't understand the code
  // try to understand the spec.
 
  // in forward case, the Path parametrs of the request are what you
  // expect, so we just do a new processRequest on the modified request

  // set the context - no need to fire context parsing again
  realRequest.setContext( context );
 
  realRequest.requestURI().setString( context.getPath() + path );
  // # 3162
  realRequest.unparsedURI().recycle();
  //realRequest.query().recycle();
  realRequest.servletPath().recycle();
  realRequest.pathInfo().recycle();
    realRequest.setChild(null);

  // merge query string as specified in specs - before, it may affect
  // the way the request is handled by special interceptors
  if( queryString != null ) {
      // Process existing parameters, if not already done so
      // ( otherwise we'll process some twice )
      realRequest.parameters().handleQueryParameters();
      // Set the query string - the sum of the new one and old one.
      String oldQS=realRequest.queryString().toString();
      String newQS=(oldQS==null ) ? queryString : queryString + "&" +
    oldQS;
      realRequest.queryString().setString(newQS);

      // Process the additional parsm. We don't know if the old
      // params were processed ( so we need to make sure they are,
      // i.e. a known state ).
      realRequest.parameters().push();
      Parameters child=realRequest.parameters().getCurrentSet();

      child.processParameters( queryString );
      //realRequest.parameters().processParameters( queryString );
  }
 
  // run the new request through the context manager
  // not that this is a very particular case of forwarding
  context.getContextManager().processRequest(realRequest);

  // unset "included" attribute if any - we may be in a servlet
  // included from another servlet,
  // in which case the attribute will create problems
  realRequest.removeAttribute( A_REQUEST_URI);
  realRequest.removeAttribute( A_SERVLET_PATH);

  // CM should have set the wrapper - call it
  Handler wr=realRequest.getHandler();
  if( wr!=null ) {
      try {
    wr.service(realRequest, realResponse);
      } catch( Exception ex ) {
    realResponse.setErrorException(ex);
      }
  }

  // Clean up the request and response as needed
  // No action required

  if ( realResponse.isExceptionPresent() ) {
      // if error URI not set, set our URI
      if ( null == realResponse.getErrorURI() )
    realResponse.setErrorURI( context.getPath() + path );
      Exception ex = realResponse.getErrorException();
      wrapException( ex,
         sm.getString("dispatcher.forwardException"));
  }
 
  // close the response - output after this point will be discarded.
  // XXX XXX Maybe this is Henri's bug !!!
  realResponse.finish();
    }
View Full Code Here

    private void doInclude(ServletRequest request, ServletResponse response)
  throws ServletException, IOException
    {
        Request realRequest = ((HttpServletRequestFacade)request).
      getRealRequest();
  Response realResponse = realRequest.getResponse();
 

  if( debug ) {
      System.out.println("RDI: doInclude: " + path + " " + name +
             " " + queryString );
  }
 
  // the strange case in a separate method
  if( name!=null) {
      includeNamed( request, response );
      return;
  }

  // Implement the spec that "no changes in response, only write"
  // can also be done by setting the response to 0.9 mode
  //  IncludedResponse iResponse = new IncludedResponse(realResponse);
  boolean old_included=realResponse.isIncluded();
  if( ! old_included ) {
      realResponse.setIncluded( true );
  }

  // We need to pass the original request, with all the paths -
  // and the new paths in special attributes.

  // We still need to find out where do we want to go ( today )
  // That means we create a subRequest with the new paths ( since
  // the mapping and aliasing is done on Requests), and run it
  // through prepare.

  // That also means that some special cases ( like the invoker !! )
  // will have to pay attention to the attributes, or we'll get a loop

  Request subRequest=context.getContextManager().
      createRequest( context, path );
  subRequest.setParent( realRequest );
  subRequest.getTop(); // control inclusion depth

  // I hope no interceptor (or code) in processRequest use any
  // of the original request info ( like Auth headers )
  //
  // XXX We need to clone the request, so that processRequest can
  // make an informed mapping ( Auth, Authorization, etc)
  //
  // This will never work corectly unless we do a full clone - but
  // for simple cases ( no auth, etc) it does

  // note that we also need a dummy response - SessionInterceptors may
  // change something !
  subRequest.setResponse( realResponse );
 
  context.getContextManager().processRequest(subRequest);
 
  // Now subRequest containse the processed and aliased paths, plus
  // the wrapper that will handle the request.

  // We will use the stack a bit - save all path attributes, set the
  // new values, and after return from wrapper revert to the original
  Object old_request_uri=replaceAttribute(realRequest, A_REQUEST_URI,
            context.getPath() + path );
  Object old_context_path=replaceAttribute(realRequest, A_CONTEXT_PATH,
             context.getPath());
  Object old_servlet_path=replaceAttribute(realRequest, A_SERVLET_PATH,
           subRequest.servletPath().toString());
  Object old_path_info=replaceAttribute(realRequest, A_PATH_INFO,
            subRequest.pathInfo().toString());
  Object old_query_string=replaceAttribute(realRequest, A_QUERY_STRING,
             queryString);

  if( debug ) {
      System.out.println("RDI: old " + old_request_uri + " " +
             old_context_path + " " + old_servlet_path +
             " " + old_path_info + " " + old_query_string);
      System.out.println("RDI: new "+context.getPath() + " " + path + " "
             + subRequest.servletPath().toString() + " " +
             subRequest.pathInfo().toString() + " " +
             queryString);
  }

  if( queryString != null ) {
      // the original parameters will be preserved, and a new
      // child Parameters will be used for the included request.
      realRequest.parameters().push();
      Parameters child=realRequest.parameters().getCurrentSet();

      child.processParameters( queryString );
     
  }

  Request old_child = realRequest.getChild();
  subRequest.setParent( old_child );
  realRequest.setChild( subRequest );
 
   // now it's really strange: we call the wrapper on the subrequest
  // for the realRequest ( since the real request will still have the
  // original handler/wrapper )

  Handler wr=subRequest.getHandler();
  if( wr!=null ) {
      try {
    wr.service(realRequest, realResponse);
      } catch( Exception ex ) {
    realResponse.setErrorException(ex);
      }
  }

 
  // After request, we want to restore the include attributes - for
  // chained includes.

  realRequest.setChild( old_child );

  if( queryString != null ) {
      // restore the parameters
      realRequest.parameters().pop();
  }
  //realRequest.setParameters( old_parameters);

  replaceAttribute( realRequest, A_REQUEST_URI, old_request_uri);
  replaceAttribute( realRequest, A_CONTEXT_PATH,old_context_path);
  replaceAttribute( realRequest, A_SERVLET_PATH, old_servlet_path);
  replaceAttribute( realRequest, A_PATH_INFO, old_path_info);
  replaceAttribute( realRequest, A_QUERY_STRING, old_query_string);
 
  // revert to the response behavior
  if( ! old_included ) {
      realResponse.setIncluded( false );
  }

  // Rethrow original error if present
  if ( realResponse.isExceptionPresent() ) {
      // if error URI not set, set our URI
      if ( null == realResponse.getErrorURI() )
    realResponse.setErrorURI( context.getPath() + path );
      Exception ex = realResponse.getErrorException();
      wrapException( ex, sm.getString("dispatcher.includeException"));
  }
    }
View Full Code Here

    {
  // We got here if name!=null, so assert it
  Handler wr = context.getServletByName( name );
  // Use the original request - as in specification !
  Request realRequest=((HttpServletRequestFacade)request).getRealRequest();
  Response realResponse = realRequest.getResponse();

  // Set the "included" flag so that things like header setting in the
  // included servlet will be correctly ignored
  boolean old_included=realResponse.isIncluded();
  if( ! old_included ) realResponse.setIncluded( true );

  if( wr!=null) {
      try {
    wr.service(realRequest, realResponse);
      } catch( Exception ex ) {
    realResponse.setErrorException( ex );
      }
  }

        // Clean up the request and response as needed
  if( ! old_included ) {
      realResponse.setIncluded( false );
  }

  // Rethrow original error if present
  if ( realResponse.isExceptionPresent() ) {
      // if error URI not set, set our URI
      if ( null == realResponse.getErrorURI() )
    realResponse.setErrorURI( "named servlet: " + name );
      wrapException( realResponse.getErrorException(),
         sm.getString("dispatcher.includeException"));
  }
    }
View Full Code Here

  Handler wr = context.getServletByName( name );

  // Use the original request - as in specification !
  Request realRequest=((HttpServletRequestFacade)request).
      getRealRequest();
  Response realResponse = realRequest.getResponse();

  // Don't set included #3726
  //   boolean old_included=realResponse.isIncluded();
  //   if( ! old_included ) realResponse.setIncluded( true );

  if( wr!=null) {
      try {
    wr.service(realRequest, realResponse);
      } catch( Exception ex ) {
    wrapException( ex, null );
      }
  }

  // Clean up the request and response as needed
  // No action required

  // Rethrow original error if present
  if ( realResponse.isExceptionPresent() ) {
      // if error URI not set, set our URI
      if ( null == realResponse.getErrorURI() )
    realResponse.setErrorURI( "named servlet: " + name );
      wrapException( realResponse.getErrorException(),
         sm.getString("dispatcher.forwardException"));
  }
    }   
View Full Code Here

  Ajp14Request req=null;
  if( thData != null ) {
      req=(Ajp14Request)thData[0];
  }
  if( req != null ) {
      Response res=req.getResponse();
      req.recycle();
      res.recycle();
      // make the note available to other modules
      req.setNote( ajp14_note, req.ajp13);
      return req;
  }
  // either thData==null or broken ( req==null)
View Full Code Here

  Ajp14Request req=null;
  if( thData != null ) {
      req=(Ajp14Request)thData[0];
  }
  if( req != null ) {
      Response res=req.getResponse();
      req.recycle();
      res.recycle();
      // make the note available to other modules
      req.setNote( ajp14_note, req.ajp13);
      return req;
  }
  // either thData==null or broken ( req==null)
View Full Code Here

  Ajp14Request req=null;
  if( thData != null ) {
      req=(Ajp14Request)thData[0];
  }
  if( req != null ) {
      Response res=req.getResponse();
      req.recycle();
      res.recycle();
      // make the note available to other modules
      req.setNote( ajp14_note, req.ajp13);
      return req;
  }
  // either thData==null or broken ( req==null)
View Full Code Here

TOP

Related Classes of org.apache.tomcat.core.Response

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.