Interface Response
-
- All Known Implementing Classes:
MockResponse
,ServletResponse
public interface Response
An abstraction of a response to a client in a web environment, that allows WComponents to function similarly when running in e.g. Servlet or Portlet environment.- Since:
- 1.0.0
- Author:
- James Gifford, 6/07/2005, Martin Shevchenko
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description OutputStream
getOutputStream()
PrintWriter
getWriter()
void
sendError(int code, String description)
void
sendRedirect(String redirect)
Sends a redirect response to the client using the specified redirect URL.void
setContentType(String contentType)
Sets the content type of the response being sent to the client.void
setHeader(String name, String value)
Sets a response header with the given name and value.
-
-
-
Method Detail
-
getWriter
PrintWriter getWriter() throws IOException
- Returns:
- a PrintWriter object that can return character data to the client.
- Throws:
IOException
- if there is an error obtaining the writer.
-
getOutputStream
OutputStream getOutputStream() throws IOException
- Returns:
- an output stream which can return character or binary data to the client.
- Throws:
IOException
- if there is an error obtaining the stream.
-
sendRedirect
void sendRedirect(String redirect) throws IOException
Sends a redirect response to the client using the specified redirect URL. Normally, no further data will be written back to the client.- Parameters:
redirect
- the URL to redirect to.- Throws:
IOException
- if there is an error sending the redirect.
-
setContentType
void setContentType(String contentType)
Sets the content type of the response being sent to the client.- Parameters:
contentType
- a String specifying the MIME type of the content, e.g. text/html.
-
setHeader
void setHeader(String name, String value)
Sets a response header with the given name and value. If the header had already been set, the new value overwrites the previous one.- Parameters:
name
- the name of the headervalue
- the header value
-
sendError
void sendError(int code, String description) throws IOException
- Parameters:
code
- the error code to returndescription
- the description of the error- Throws:
IOException
- an IO exception has occurred trying to send the error
-
-