package org.apache.wicket;
Abstract base class for different implementations of response writing. A subclass must implement
write(String) to write a String to the response destination (whether it be a browser, a file, a
test harness or some other place). A subclass may optionally implement close(),
encodeURL(String), redirect(String), isRedirect() or setContentType(String) as appropriate.
Default encoding of output stream
Closes the response output stream
Called when the Response needs to reset itself. Subclasses can empty there buffer or build up
state.
An implementation of this method is only required if a subclass wishes to support sessions
via URL rewriting. This default implementation simply returns the URL String it is passed.
- Parameters:
url
The URL to encode- Returns:
- The encoded url
THIS METHOD IS NOT PART OF THE WICKET PUBLIC API. DO NOT USE IT.
Loops over all the response filters that were set (if any) with the give response returns the
response buffer itself if there where now filters or the response buffer that was
created/returned by the filter(s)
- Parameters:
responseBuffer
The response buffer to be filtered- Returns:
- Returns the filtered string buffer.
if (responseFilters == null)
for (int i = 0; i < responseFilters.size(); i++)
responseBuffer = filter.filter(responseBuffer);
- Returns:
- The output stream for this response
Returns true if a redirection has occurred. The default implementation always returns false
since redirect is not implemented by default.
- Returns:
- True if the redirect method has been called, making this response a redirect.
CLIENTS SHOULD NEVER CALL THIS METHOD FOR DAY TO DAY USE!
A subclass may override this method to implement redirection. Subclasses which have no need
to do redirection may choose not to override this default implementation, which does nothing.
For example, if a subclass wishes to write output to a file or is part of a testing harness,
there may be no meaning to redirection.
Framework users who want to redirect should use a construction like
RequestCycle.get().setRequestTarget(new RedirectRequestTarget(...));
or
setResponsePage(new RedirectPage(...));
- Parameters:
url
The URL to redirect to
Set the default encoding for the output. Note: It is up to the derived class to make use of
the information. Class Response simply stores the value, but does not apply it anywhere
automatically.
Set the content length on the response, if appropriate in the subclass. This default
implementation does nothing.
- Parameters:
length
The length of the content
Set the content type on the response, if appropriate in the subclass. This default
implementation does nothing.
- Parameters:
mimeType
The mime type
Set the contents last modified time, if appropriate in the subclass. This default
implementation does nothing.
- Parameters:
time
The time object
- Parameters:
locale
Locale to use for this response
Writes the given tag to via the write(String) abstract method.
- Parameters:
tag
The tag to write
Writes the given string to the Response subclass output destination.
- Parameters:
string
The string to write
Either throws the exception wrapped as
WicketRuntimeException or silently ignores it.
This method should ignore IO related exceptions like connection reset by peer or broken pipe.
boolean ignoreException = false;
while (throwable != null)
ignoreException = message != null &&
(message.indexOf("Connection reset") != -1 || message.indexOf("Broken pipe") != -1 || message.indexOf("Socket closed") != -1 || message.indexOf("connection abort") != -1); log.debug("Socket exception ignored for sending Resource " + "response to client (ClientAbort)", e);
Copies the given input stream to the servlet response
NOTE Content-Length is not set because it would require to buffer the whole input stream
- Parameters:
in
input stream to copy, will be closed after copy
Writes the given string to the Response subclass output destination and appends a cr/nl
depending on the OS
Sets the Content-Type header with servlet-context-defined content-types (application's
web.xml or servlet container's configuration), and fall back to system or JVM-defined
(FileNameMap) content types.