本文整理汇总了Java中org.apache.catalina.Response类的典型用法代码示例。如果您正苦于以下问题:Java Response类的具体用法?Java Response怎么用?Java Response使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Response类属于org.apache.catalina包,在下文中一共展示了Response类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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);
}
}
示例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);
}
}
示例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);
}
示例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("------------------------------------");
}
示例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();
}
示例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);
}
示例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);
}
示例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);
}
}
示例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);
}
}
示例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);
}
示例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();
}
}
示例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);
}
示例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);
}
}
}
示例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");
}
}