String stringValue = null;
try {
// Ask the Portlet Container for a BaseURL that contains the modified parameters.
BaseURL baseURL = toBaseURL();
// If the URL string has escaped characters (like %20 for space, etc) then ask the
// portlet container to create an escaped representation of the URL string.
if (isEscaped()) {
StringWriter urlWriter = new StringWriter();
try {
baseURL.write(urlWriter, true);
}
catch (IOException e) {
logger.error(e);
stringValue = baseURL.toString();
}
stringValue = urlWriter.toString();
}
// Otherwise, ask the portlet container to create a normal (non-escaped) string
// representation of the URL string.
else {
stringValue = baseURL.toString();
}
}
catch (MalformedURLException e) {
logger.error(e);
}