org.apache.struts.util

Class ResponseUtils


public class ResponseUtils
extends java.lang.Object

General purpose utility methods related to generating a servlet response in the Struts controller framework.
Version:
$Rev: 164747 $ $Date: 2005-04-26 06:47:48 +0100 (Tue, 26 Apr 2005) $

Field Summary

private static Method
encode
Java 1.4 encode method to use instead of deprecated 1.3 version.
private static Log
log
Commons logging instance.
protected static MessageResources
messages
The message resources for this package.

Method Summary

static String
encodeURL(String url)
URLencodes a string assuming the character encoding is UTF-8.
static String
encodeURL(String url, String enc)
Use the new URLEncoder.encode() method from Java 1.4 if available, else use the old deprecated version.
static String
filter(String value)
Filter the specified string for characters that are sensitive to HTML interpreters, returning the string with these characters replaced by the corresponding character entities.
static void
write(PageContext pageContext, String text)
Deprecated. use TagUtils.write() method instead.
static void
writePrevious(PageContext pageContext, String text)
Deprecated. use TagUtils.writePrevious() method instead.

Field Details

encode

private static Method encode
Java 1.4 encode method to use instead of deprecated 1.3 version.

log

private static final Log log
Commons logging instance.

messages

protected static MessageResources messages
The message resources for this package.

Method Details

encodeURL

public static String encodeURL(String url)
URLencodes a string assuming the character encoding is UTF-8.
Parameters:
url -
Returns:
String The encoded url in UTF-8

encodeURL

public static String encodeURL(String url,
                               String enc)
Use the new URLEncoder.encode() method from Java 1.4 if available, else use the old deprecated version. This method uses reflection to find the appropriate method; if the reflection operations throw exceptions, this will return the url encoded with the old URLEncoder.encode() method.
Parameters:
enc - The character encoding the urlencode is performed on.
Returns:
String The encoded url.

filter

public static String filter(String value)
Filter the specified string for characters that are sensitive to HTML interpreters, returning the string with these characters replaced by the corresponding character entities.
Parameters:
value - The string to be filtered and returned

write

public static void write(PageContext pageContext,
                         String text)
            throws JspException

Deprecated. use TagUtils.write() method instead. This method will be removed after Struts 1.2.

Write the specified text as the response to the writer associated with this page. WARNING - If you are writing body content from the doAfterBody() method of a custom tag class that implements BodyTag, you should be calling writePrevious() instead.
Parameters:
pageContext - The PageContext object for this page
text - The text to be written

writePrevious

public static void writePrevious(PageContext pageContext,
                                 String text)
            throws JspException

Deprecated. use TagUtils.writePrevious() method instead. This method will be removed after Struts 1.2.

Write the specified text as the response to the writer associated with the body content for the tag within which we are currently nested.
Parameters:
pageContext - The PageContext object for this page
text - The text to be written

Copyright B) 2000-2007 - The Apache Software Foundation