• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java Response类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.apache.catalina.Response的典型用法代码示例。如果您正苦于以下问题:Java Response类的具体用法?Java Response怎么用?Java Response使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Response类属于org.apache.catalina包,在下文中一共展示了Response类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: invoke

import org.apache.catalina.Response; //导入依赖的package包/类
@Override
public int invoke(Request rqst, Response rspns) throws IOException,
        ServletException {
    if (!isStarted()) {
        try {
            start();
        } catch (LifecycleException ex) {
            throw new ServletException(ex);
        }
    }
    rqst.setNote(CatalinaAdapter.REQUEST_TIME, System.currentTimeMillis());
    if (!alreadySetLogbackStatusManager) {
        alreadySetLogbackStatusManager = true;
        org.apache.catalina.Context tomcatContext = rqst.getContext();
        if (tomcatContext != null) {
            ServletContext sc = tomcatContext.getServletContext();
            if (sc != null) {
                sc.setAttribute(AccessConstants.LOGBACK_STATUS_MANAGER_KEY, ctx.getStatusManager());
            }
        }
    }

    return INVOKE_NEXT;
}
 
开发者ID:goodees,项目名称:goodees,代码行数:25,代码来源:CatalinaValve.java


示例2: postInvoke

import org.apache.catalina.Response; //导入依赖的package包/类
@Override
public void postInvoke(Request request, Response response)
        throws IOException, ServletException {
    final HttpServletRequest httpRequest = (HttpServletRequest) request.getRequest();
    try {
        CatalinaAdapter adapter = new CatalinaAdapter(request, response);
        IAccessEvent accessEvent = new AccessEvent(httpRequest, (HttpServletResponse) response.getResponse(),
            adapter);

        if (ctx.getFilterChainDecision(accessEvent) == FilterReply.DENY) {
            return;
        }

        // TODO better tion handling
        ctx.callAppenders(accessEvent);
    } finally {
        httpRequest.removeAttribute(AccessConstants.LOGBACK_STATUS_MANAGER_KEY);
    }
}
 
开发者ID:goodees,项目名称:goodees,代码行数:20,代码来源:CatalinaValve.java


示例3: invoke

import org.apache.catalina.Response; //导入依赖的package包/类
/**
 * Invoke the next Valve in the sequence. When the invoke returns, check 
 * the response state, and output an error report is necessary.
 *
 * @param request The servlet request to be processed
 * @param response The servlet response to be created
 * @param context The valve context used to invoke the next valve
 *  in the current processing pipeline
 *
 * @exception IOException if an input/output error occurs
 * @exception ServletException if a servlet error occurs
 */
public void invoke(Request request, Response response,
                   ValveContext context)
    throws IOException, ServletException {

    // Perform the request
    context.invokeNext(request, response);

    response.setSuspended(false);

    ServletRequest sreq = request.getRequest();
    Throwable t = (Throwable) sreq.getAttribute(Globals.EXCEPTION_ATTR);

    if (t != null) {
        throwable(request, response, t);
    } else {
        status(request, response);
    }

}
 
开发者ID:c-rainstorm,项目名称:jerrydog,代码行数:32,代码来源:ErrorDispatcherValve.java


示例4: invoke

import org.apache.catalina.Response; //导入依赖的package包/类
/**
 * Expose the certificates chain if one was included on this request.
 *
 * @param request The servlet request to be processed
 * @param response The servlet response to be created
 * @param context The valve context used to invoke the next valve
 *  in the current processing pipeline
 *
 * @exception IOException if an input/output error occurs
 * @exception ServletException if a servlet error occurs
 */
public void invoke(Request request, Response response,
                   ValveContext context)
    throws IOException, ServletException {

    // Identify the underlying request if this request was wrapped
    Request actual = request;
    while (actual instanceof RequestWrapper)
        actual = ((RequestWrapper) actual).getWrappedRequest();
    //        if (debug >= 2)
    //            log("Processing request");

    // Verify the existence of a certificate chain if appropriate
    if (certificates)
        verify(request, actual);

    // Expose the certificate chain if appropriate
    expose(request, actual);

    // Invoke the next Valve in our Pipeline
    context.invokeNext(request, response);

}
 
开发者ID:c-rainstorm,项目名称:jerrydog,代码行数:34,代码来源:CertificatesValve.java


示例5: invoke

import org.apache.catalina.Response; //导入依赖的package包/类
public void invoke(Request request, Response response, ValveContext valveContext)
  throws IOException, ServletException {

  // Pass this request on to the next valve in our pipeline
  valveContext.invokeNext(request, response);

  System.out.println("Header Logger Valve");
  ServletRequest sreq = request.getRequest();
  if (sreq instanceof HttpServletRequest) {
    HttpServletRequest hreq = (HttpServletRequest) sreq;
    Enumeration headerNames = hreq.getHeaderNames();
    while (headerNames.hasMoreElements()) {
      String headerName = headerNames.nextElement().toString();
      String headerValue = hreq.getHeader(headerName);
      System.out.println(headerName + ":" + headerValue);
    }

  }
  else
    System.out.println("Not an HTTP Request");

  System.out.println("------------------------------------");
}
 
开发者ID:eclipsky,项目名称:HowTomcatWorks,代码行数:24,代码来源:HeaderLoggerValve.java


示例6: ResponseStream

import org.apache.catalina.Response; //导入依赖的package包/类
/**
 * Construct a servlet output stream associated with the specified Request.
 *
 * @param response The associated response
 */
public ResponseStream(Response response) {

    super();
    closed = false;
    commit = false;
    count = 0;
    this.response = response;
    this.stream = response.getStream();
    this.suspended = response.isSuspended();

}
 
开发者ID:c-rainstorm,项目名称:jerrydog,代码行数:17,代码来源:ResponseStream.java


示例7: createResponse

import org.apache.catalina.Response; //导入依赖的package包/类
/**
 * Create (or allocate) and return a Response object suitable for
 * receiving the contents of a Response from the responsible Container.
 */
public Response createResponse() {

    //        if (debug >= 2)
    //            log("createResponse: Creating new response");
    HttpResponseImpl response = new HttpResponseImpl();
    response.setConnector(this);
    return (response);

}
 
开发者ID:c-rainstorm,项目名称:jerrydog,代码行数:14,代码来源:HttpConnector.java


示例8: createResponse

import org.apache.catalina.Response; //导入依赖的package包/类
/**
 * Create (or allocate) and return a Response object suitable for
 * receiving the contents of a Response from the responsible Container.
 */
public Response createResponse() {

    HttpResponseImpl response = new HttpResponseImpl();
    response.setConnector(this);
    return (response);

}
 
开发者ID:c-rainstorm,项目名称:jerrydog,代码行数:12,代码来源:HttpConnector.java


示例9: custom

import org.apache.catalina.Response; //导入依赖的package包/类
/**
 * Handle an HTTP status code or Java exception by forwarding control
 * to the location included in the specified errorPage object.  It is
 * assumed that the caller has already recorded any request attributes
 * that are to be forwarded to this page.  Return <code>true</code> if
 * we successfully utilized the specified error page location, or
 * <code>false</code> if the default error report should be rendered.
 *
 * @param request The request being processed
 * @param response The response being generated
 * @param errorPage The errorPage directive we are obeying
 */
protected boolean custom(Request request, Response response,
                         ErrorPage errorPage) {

    if (debug >= 1)
        log("Processing " + errorPage);

    // Validate our current environment
    if (!(request instanceof HttpRequest)) {
        if (debug >= 1)
            log(" Not processing an HTTP request --> default handling");
        return (false);     // NOTE - Nothing we can do generically
    }
    HttpServletRequest hreq =
        (HttpServletRequest) request.getRequest();
    if (!(response instanceof HttpResponse)) {
        if (debug >= 1)
            log("Not processing an HTTP response --> default handling");
        return (false);     // NOTE - Nothing we can do generically
    }
    HttpServletResponse hres =
        (HttpServletResponse) response.getResponse();

    try {

        // Reset the response if possible (else IllegalStateException)
        hres.reset();

        // Forward control to the specified location
        ServletContext servletContext =
            request.getContext().getServletContext();
        RequestDispatcher rd =
            servletContext.getRequestDispatcher(errorPage.getLocation());
        rd.forward(hreq, hres);

        // If we forward, the response is suspended again
        response.setSuspended(false);

        // Indicate that we have successfully processed this custom page
        return (true);

    } catch (Throwable t) {

        // Report our failure to process this custom page
        log("Exception Processing " + errorPage, t);
        return (false);

    }

}
 
开发者ID:c-rainstorm,项目名称:jerrydog,代码行数:62,代码来源:ErrorDispatcherValve.java


示例10: invoke

import org.apache.catalina.Response; //导入依赖的package包/类
/**
 * Process the specified Request, and generate the corresponding Response,
 * according to the design of this particular Container.
 *
 * @param request Request to be processed
 * @param response Response to be produced
 *
 * @exception IOException if an input/output error occurred while
 *  processing
 * @exception ServletException if a ServletException was thrown
 *  while processing this request
 */
public void invoke(Request request, Response response)
    throws IOException, ServletException {

    // Wait if we are reloading
    while (getPaused()) {
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            ;
        }
    }

    // Normal request processing
    if (swallowOutput) {
        try {
            SystemLogHandler.startCapture();
            super.invoke(request, response);
        } finally {
            String log = SystemLogHandler.stopCapture();
            if (log != null && log.length() > 0) {
                log(log);
            }
        }
    } else {
        super.invoke(request, response);
    }

}
 
开发者ID:c-rainstorm,项目名称:jerrydog,代码行数:41,代码来源:StandardContext.java


示例11: invoke

import org.apache.catalina.Response; //导入依赖的package包/类
/**
 * Select the appropriate child Host to process this request,
 * based on the requested server name.  If no matching Host can
 * be found, return an appropriate HTTP error.
 *
 * @param request Request to be processed
 * @param response Response to be produced
 * @param valveContext Valve context used to forward to the next Valve
 *
 * @exception IOException if an input/output error occurred
 * @exception ServletException if a servlet error occurred
 */
public void invoke(Request request, Response response,
                   ValveContext valveContext)
    throws IOException, ServletException {
    // Validate the request and response object types
    if (!(request.getRequest() instanceof HttpServletRequest) ||
        !(response.getResponse() instanceof HttpServletResponse)) {
        return;     // NOTE - Not much else we can do generically
    }

    // Validate that any HTTP/1.1 request included a host header
    HttpServletRequest hrequest = (HttpServletRequest) request;
    if ("HTTP/1.1".equals(hrequest.getProtocol()) &&
        (hrequest.getServerName() == null)) {
        ((HttpServletResponse) response.getResponse()).sendError
            (HttpServletResponse.SC_BAD_REQUEST,
             sm.getString("standardEngine.noHostHeader",
                          request.getRequest().getServerName()));
        return;
    }

    // Select the Host to be used for this Request
    StandardEngine engine = (StandardEngine) getContainer();
    Host host = (Host) engine.map(request, true);
    if (host == null) {
        ((HttpServletResponse) response.getResponse()).sendError
            (HttpServletResponse.SC_BAD_REQUEST,
             sm.getString("standardEngine.noHost",
                          request.getRequest().getServerName()));
        return;
    }

    // Ask this Host to process this request
    host.invoke(request, response);

}
 
开发者ID:c-rainstorm,项目名称:jerrydog,代码行数:48,代码来源:StandardEngineValve.java


示例12: unwrapResponse

import org.apache.catalina.Response; //导入依赖的package包/类
/**
 * Unwrap the response if we have wrapped it.
 */
private void unwrapResponse() {

    if (wrapResponse == null)
        return;

    ServletResponse previous = null;
    ServletResponse current = outerResponse;
    while (current != null) {

        // If we run into the container response we are done
        if ((current instanceof Response) 
            || (current instanceof ResponseFacade))
            break;

        // Remove the current response if it is our wrapper
        if (current == wrapResponse) {
            ServletResponse next =
              ((ServletResponseWrapper) current).getResponse();
            if (previous == null)
                outerResponse = next;
            else
                ((ServletResponseWrapper) previous).setResponse(next);
            break;
        }

        // Advance to the next response in the chain
        previous = current;
        current = ((ServletResponseWrapper) current).getResponse();

    }

}
 
开发者ID:c-rainstorm,项目名称:jerrydog,代码行数:36,代码来源:ApplicationDispatcher.java


示例13: wrapResponse

import org.apache.catalina.Response; //导入依赖的package包/类
/**
 * Create and return a response wrapper that has been inserted in the
 * appropriate spot in the response chain.
 */
private ServletResponse wrapResponse() {

    // Locate the response we should insert in front of
    ServletResponse previous = null;
    ServletResponse current = outerResponse;
    while (current != null) {
        if (!(current instanceof ServletResponseWrapper))
            break;
        if (current instanceof ApplicationHttpResponse)
            break;
        if (current instanceof ApplicationResponse)
            break;
        if (current instanceof Response)
            break;
        previous = current;
        current = ((ServletResponseWrapper) current).getResponse();
    }

    // Instantiate a new wrapper at this point and insert it in the chain
    ServletResponse wrapper = null;
    if ((current instanceof ApplicationHttpResponse) ||
        (current instanceof HttpResponse) ||
        (current instanceof HttpServletResponse))
        wrapper =
            new ApplicationHttpResponse((HttpServletResponse) current,
                                        including);
    else
        wrapper = new ApplicationResponse(current, including);
    if (previous == null)
        outerResponse = wrapper;
    else
        ((ServletResponseWrapper) previous).setResponse(wrapper);
    wrapResponse = wrapper;
    return (wrapper);

}
 
开发者ID:c-rainstorm,项目名称:jerrydog,代码行数:41,代码来源:ApplicationDispatcher.java


示例14: invoke

import org.apache.catalina.Response; //导入依赖的package包/类
public void invoke(Request request, Response response, ValveContext valveContext) throws IOException, ServletException {
    valveContext.invokeNext(request, response);
    ServletRequest servletRequest = request.getRequest();
    if (servletRequest instanceof HttpServletRequest) {
        HttpServletRequest hsr = (HttpServletRequest) request;
        HttpSession session = hsr.getSession(false);
        if (session != null) {
            String ip = IPInfo.getClientAddress(hsr);
            session.setAttribute(ApplicationSession.LAST_ACCESSED_BY_IP, ip);
        }
    }
}
 
开发者ID:andresol,项目名称:psi-probe-plus,代码行数:13,代码来源:Tomcat50AgentValve.java


示例15: invokeNext

import org.apache.catalina.Response; //导入依赖的package包/类
public void invokeNext(Request request, Response response)
  throws IOException, ServletException {
  int subscript = stage;
  stage = stage + 1;
  // Invoke the requested Valve for the current request thread
  if (subscript < valves.length) {
    valves[subscript].invoke(request, response, this);
  }
  else if ((subscript == valves.length) && (basic != null)) {
    basic.invoke(request, response, this);
  }
  else {
    throw new ServletException("No valve");
  }
}
 
开发者ID:eclipsky,项目名称:HowTomcatWorks,代码行数:16,代码来源:SimplePipeline.java


示例16: invoke

import org.apache.catalina.Response; //导入依赖的package包/类
public void invoke(Request request, Response response, ValveContext valveContext)
  throws IOException, ServletException {

  SimpleWrapper wrapper = (SimpleWrapper) getContainer();
  ServletRequest sreq = request.getRequest();
  ServletResponse sres = response.getResponse();
  Servlet servlet = null;
  HttpServletRequest hreq = null;
  if (sreq instanceof HttpServletRequest)
    hreq = (HttpServletRequest) sreq;
  HttpServletResponse hres = null;
  if (sres instanceof HttpServletResponse)
    hres = (HttpServletResponse) sres;

  //-- new addition -----------------------------------
  Context context = (Context) wrapper.getParent();
  request.setContext(context);
  //-------------------------------------
  // Allocate a servlet instance to process this request
  try {
    servlet = wrapper.allocate();
    if (hres!=null && hreq!=null) {
      servlet.service(hreq, hres);
    }
    else {
      servlet.service(sreq, sres);
    }
  }
  catch (ServletException e) {
  }
}
 
开发者ID:eclipsky,项目名称:HowTomcatWorks,代码行数:32,代码来源:SimpleWrapperValve.java


示例17: invoke

import org.apache.catalina.Response; //导入依赖的package包/类
public void invoke(Request request, Response response, ValveContext valveContext)
  throws IOException, ServletException {
  // Validate the request and response object types
  if (!(request.getRequest() instanceof HttpServletRequest) ||
    !(response.getResponse() instanceof HttpServletResponse)) {
    return;     // NOTE - Not much else we can do generically
  }

  // Disallow any direct access to resources under WEB-INF or META-INF
  HttpServletRequest hreq = (HttpServletRequest) request.getRequest();
  String contextPath = hreq.getContextPath();
  String requestURI = ((HttpRequest) request).getDecodedRequestURI();
  String relativeURI =
    requestURI.substring(contextPath.length()).toUpperCase();

  Context context = (Context) getContainer();
  // Select the Wrapper to be used for this Request
  Wrapper wrapper = null;
  try {
    wrapper = (Wrapper) context.map(request, true);
  }
  catch (IllegalArgumentException e) {
    badRequest(requestURI, (HttpServletResponse) response.getResponse());
    return;
  }
  if (wrapper == null) {
    notFound(requestURI, (HttpServletResponse) response.getResponse());
    return;
  }
  // Ask this Wrapper to process this Request
  response.setContext(context);
  wrapper.invoke(request, response);
}
 
开发者ID:eclipsky,项目名称:HowTomcatWorks,代码行数:34,代码来源:SimpleContextValve.java


示例18: invoke

import org.apache.catalina.Response; //导入依赖的package包/类
public void invoke(Request request, Response response, ValveContext valveContext)
  throws IOException, ServletException {

  SimpleWrapper wrapper = (SimpleWrapper) getContainer();
  ServletRequest sreq = request.getRequest();
  ServletResponse sres = response.getResponse();
  Servlet servlet = null;
  HttpServletRequest hreq = null;
  if (sreq instanceof HttpServletRequest)
    hreq = (HttpServletRequest) sreq;
  HttpServletResponse hres = null;
  if (sres instanceof HttpServletResponse)
    hres = (HttpServletResponse) sres;

  // Allocate a servlet instance to process this request
  try {
    servlet = wrapper.allocate();
    if (hres!=null && hreq!=null) {
      servlet.service(hreq, hres);
    }
    else {
      servlet.service(sreq, sres);
    }
  }
  catch (ServletException e) {
  }
}
 
开发者ID:eclipsky,项目名称:HowTomcatWorks,代码行数:28,代码来源:SimpleWrapperValve.java


示例19: invoke

import org.apache.catalina.Response; //导入依赖的package包/类
public void invoke(Request request, Response response, ValveContext valveContext)
  throws IOException, ServletException {

  // Pass this request on to the next valve in our pipeline
  valveContext.invokeNext(request, response);
  System.out.println("Client IP Logger Valve");
  ServletRequest sreq = request.getRequest();
  System.out.println(sreq.getRemoteAddr());
  System.out.println("------------------------------------");
}
 
开发者ID:eclipsky,项目名称:HowTomcatWorks,代码行数:11,代码来源:ClientIPLoggerValve.java


示例20: invoke

import org.apache.catalina.Response; //导入依赖的package包/类
@Override
public int invoke(Request rqst, Response rspns) throws IOException, ServletException {
    return delegate.invoke(rqst, rspns);
}
 
开发者ID:goodees,项目名称:goodees,代码行数:5,代码来源:Logger.java



注:本文中的org.apache.catalina.Response类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Utf8Decoder类代码示例发布时间:2022-05-22
下一篇:
Java ConnectionProperties类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap