org.apache.jetspeed.portlet
Interface PortletResponse

All Known Implementing Classes:
PortletResponseWrapper

public interface PortletResponse

The PortletResponse interface represents the response sent to the client device.

It is up to the portlet container to enhance, extend, or modify the response as required before it is actually sent to the client device.

Since:
4.1 * @deprecated since 6.0. Support of the IBM portlet API may be removed in a future release of WebSphere Portal. Use of the Java Portlet API (javax.portlet) is recommended instead.
See Also:
PortletRequest

Method Summary
 void addCookie(javax.servlet.http.Cookie cookie)
          Adds the specified cookie to the response.
 void addDateHeader(java.lang.String name, long date)
          Adds a response header with the given name and date-value.
 void addHeader(java.lang.String name, java.lang.String value)
          Adds a response header with the given name and value.
 void addIntHeader(java.lang.String name, int value)
          Adds a response header with the given name and integer value.
 boolean containsHeader(java.lang.String name)
          Returns a boolean indicating whether the named response header has already been set.
 PortletURI createReturnURI()
          Creates a portlet URI pointing at the referrer of the portlet.
 PortletURI createURI()
          Creates a portlet URI pointing to the current portlet mode.
 PortletURI createURI(PortletWindow.State state)
          Creates a portlet URI pointing to the current portlet mode and given portlet window state.
 java.lang.String encodeNamespace(java.lang.String aValue)
          Maps the given string value into this portlet's namespace.
 java.lang.String encodeURI(java.lang.String path)
          Deprecated. use encodeURL(java.lang.String) since version 1.1
 java.lang.String encodeURL(java.lang.String path)
          Returns the encoded URI of the resource at the given path.
 java.lang.String getCharacterEncoding()
          Returns the name of the charset used for the MIME body sent in this response.
 java.lang.String getCharacterSet()
          Deprecated. use getCharacterEncoding since version 1.1
 java.lang.String getContentType()
          Returns the content type that can be used to contribute markup to the portlet response.
 java.io.PrintWriter getWriter()
          Returns the writer object that can be used to contribute markup to the portlet response.
 void setDateHeader(java.lang.String name, long date)
          Sets a response header with the given name and date-value.
 void setHeader(java.lang.String name, java.lang.String value)
          Sets a response header with the given name and value.
 void setIntHeader(java.lang.String name, int value)
          Sets a response header with the given name and integer value.
 

Method Detail

getWriter

java.io.PrintWriter getWriter()
                              throws java.io.IOException
Returns the writer object that can be used to contribute markup to the portlet response.

It is important to note that the markup generated by the portlet is either a full document or just a fragment of the markup. A corresponding setting in the deployment descriptor has to be made.

Returns:
the print writer
Throws:
java.io.IOException - if the I/O operation fails

getContentType

java.lang.String getContentType()
Returns the content type that can be used to contribute markup to the portlet response.

Returns:
the content type

getCharacterEncoding

java.lang.String getCharacterEncoding()
Returns the name of the charset used for the MIME body sent in this response.

If no charset has been assigned, it is implicitly set to ISO-8859-1 (Latin-1).

See RFC 2047 (http://ds.internic.net/rfc/rfc2045.txt) for more information about character encoding and MIME.

Returns:
a String specifying the name of the charset, for example, ISO-8859-1

getCharacterSet

java.lang.String getCharacterSet()
Deprecated. use getCharacterEncoding since version 1.1

Returns the character set that can be used to contribute markup to the portlet response.

Returns:
the character set

createURI

PortletURI createURI()
Creates a portlet URI pointing to the current portlet mode. The returned URI can be further extended by adding portlet-specific parameters and by attaching an action. Also, the portlet window will stay in the same state as before.

Returns:
a portlet URI

createURI

PortletURI createURI(PortletWindow.State state)
Creates a portlet URI pointing to the current portlet mode and given portlet window state. The returned URI can be further extended by adding portlet-specific parameters and by attaching an action.

Parameters:
state - the portlet window state
Returns:
a portlet URI

createReturnURI

PortletURI createReturnURI()
Creates a portlet URI pointing at the referrer of the portlet. This is normally the previous screen / URL shown in the browser. The returned URI can be further extended by adding portlet-specific parameters and/or by attaching an action. This method is very useful to return from the EDIT mode, for example.

Returns:
a portlet URI

encodeURI

java.lang.String encodeURI(java.lang.String path)
Deprecated. use encodeURL(java.lang.String) since version 1.1

Returns the encoded URI of the resource at the given path. Encoding may include prefixing, conversion to absolute URL, WSRP rewriting etc.

Parameters:
path - the path to the resource
Returns:
the resource URI as string
See Also:
encodeURL(java.lang.String)

encodeURL

java.lang.String encodeURL(java.lang.String path)
Returns the encoded URI of the resource at the given path. Encoding may include prefixing, conversion to absolute URL, WSRP rewriting etc.

This method must be called on all resource URLs (images etc.) before they are written to the output writer. It must not be called on portal or portlet URLs that were generated using APIs like createURI()

The given path may be a relative path inside the portlet WAR file like images/myimage.gif, which must be relative to the root of the WAR archive. For historical compatibility reasons, absolute paths that do not start with the portlet or portal context root are also treated as relative paths inside the portlet WAR; e.g. /images/myimage.gif is equivalent to images/myimage.gif.

The output of this method may not necessarily be a valid URL, it may also be a token that is later replaced in the portlet output processing. The only valid use of the this method is to write the result to the portlet output stream.

Parameters:
path - the path to the resource
Returns:
the resource URL as string

encodeNamespace

java.lang.String encodeNamespace(java.lang.String aValue)
Maps the given string value into this portlet's namespace. Should be applied to every variable or name used in the output stream. For example, a parameter used in a form, or a function name in javascript.

Parameters:
aValue - the name to be mapped
Returns:
the mapped name

addCookie

void addCookie(javax.servlet.http.Cookie cookie)
Adds the specified cookie to the response. This method can be called multiple times to set more than one cookie.

The portlet container encodes the cookie name in the concrete portlet instances' namespace.

Parameters:
cookie - the Cookie to return to the client
Throws:
java.lang.IllegalStateException - if the portlet tries to access this function outside of the beginPage method of the PortletPageListener

containsHeader

boolean containsHeader(java.lang.String name)
Returns a boolean indicating whether the named response header has already been set.

Parameters:
name - the header name
Returns:
true if the named response header has already been set; false otherwise

setDateHeader

void setDateHeader(java.lang.String name,
                   long date)
Sets a response header with the given name and date-value. The date is specified in terms of milliseconds since the epoch. If the header had already been set, the new value overwrites the previous one. The containsHeader method can be used to test for the presence of a header before setting its value.

We need to think about all header methods and how to solve nameclashes, etc.

Parameters:
name - the name of the header to set
value - the assigned date value
Throws:
java.lang.IllegalStateException - if the portlet tries to access this function outside of the beginPage method of the PortletPageListener or if the portlet tries to set an portal-wide header
See Also:
containsHeader(java.lang.String), addDateHeader(java.lang.String, long)

addDateHeader

void addDateHeader(java.lang.String name,
                   long date)
Adds a response header with the given name and date-value. The date is specified in terms of milliseconds since the epoch. This method allows response headers to have multiple values.

We need to think about all header methods and how to solve nameclashes, etc.

Parameters:
name - the name of the header to set
date -
Throws:
java.lang.IllegalStateException - if the portlet tries to access this function outside of the beginPage method of the PortletPageListener or if the portlet tries to set an portal-wide header
See Also:
setDateHeader(java.lang.String, long)

setHeader

void setHeader(java.lang.String name,
               java.lang.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. The containsHeader method can be used to test for the presence of a header before setting its value.

We need to think about all header methods and how to solve nameclashes, etc.

Parameters:
name - the name of the header
value - the header value
Throws:
java.lang.IllegalStateException - if the portlet tries to access this function outside of the beginPage method of the PortletPageListener or if the portlet tries to set an portal-wide header
See Also:
containsHeader(java.lang.String), addHeader(java.lang.String, java.lang.String)

addHeader

void addHeader(java.lang.String name,
               java.lang.String value)
Adds a response header with the given name and value. This method allows response headers to have multiple values.

We need to think about all header methods and how to solve nameclashes, etc.

Parameters:
name - the name of the header
value - the additional header value
Throws:
java.lang.IllegalStateException - if the portlet tries to access this function outside of the beginPage method of the PortletPageListener or if the portlet tries to set an portal-wide header
See Also:
setHeader(java.lang.String, java.lang.String)

setIntHeader

void setIntHeader(java.lang.String name,
                  int value)
Sets a response header with the given name and integer value. If the header had already been set, the new value overwrites the previous one. The containsHeader method can be used to test for the presence of a header before setting its value.

We need to think about all header methods and how to solve nameclashes, etc.

Parameters:
name - the name of the header
value - the assigned integer value
Throws:
java.lang.IllegalStateException - if the portlet tries to access this function outside of the beginPage method of the PortletPageListener or if the portlet tries to set an portal-wide header
See Also:
containsHeader(java.lang.String), addIntHeader(java.lang.String, int)

addIntHeader

void addIntHeader(java.lang.String name,
                  int value)
Adds a response header with the given name and integer value. This method allows response headers to have multiple values.

We need to think about all header methods and how to solve nameclashes, etc.

Parameters:
name - the name of the header
value - the assigned integer value
Throws:
java.lang.IllegalStateException - if the portlet tries to access this function outside of the beginPage method of the PortletPageListener or if the portlet tries to set an portal-wide header
See Also:
setIntHeader(java.lang.String, int)