public abstract class ImportSupport
extends java.lang.Object
Provides methods to import arbitrary local or remote resources as strings.
Based on ImportSupport from the JSTL taglib by Shawn Bayern
Modifier and Type | Class and Description |
---|---|
protected static class |
ImportSupport.ImportResponseWrapper
Wraps responses to allow us to retrieve results as Strings.
|
protected static class |
ImportSupport.SafeClosingHttpURLConnectionReader |
Modifier and Type | Field and Description |
---|---|
protected ServletContext |
application |
protected static java.lang.String |
DEFAULT_ENCODING
Default character encoding for response.
|
protected Log |
LOG |
protected HttpServletRequest |
request |
protected HttpServletResponse |
response |
protected static java.lang.String |
VALID_SCHEME_CHARS |
Constructor and Description |
---|
ImportSupport() |
Modifier and Type | Method and Description |
---|---|
protected java.io.Reader |
acquireReader(java.lang.String url) |
protected java.lang.String |
acquireString(java.lang.String url) |
static java.lang.String |
getContentTypeAttribute(java.lang.String input,
java.lang.String name)
Get the value associated with a content-type attribute.
|
static boolean |
isAbsoluteUrl(java.lang.String url)
Returns true if our current URL is absolute,
false otherwise.
|
void |
setLog(Log log) |
void |
setRequest(HttpServletRequest request)
Sets the current
HttpServletRequest . |
void |
setResponse(HttpServletResponse response)
Sets the current
HttpServletResponse . |
void |
setServletContext(ServletContext application)
Sets the
ServletContext . |
static java.lang.String |
stripSession(java.lang.String url)
Strips a servlet session ID from url.
|
protected static final java.lang.String VALID_SCHEME_CHARS
protected static final java.lang.String DEFAULT_ENCODING
protected Log LOG
protected ServletContext application
protected HttpServletRequest request
protected HttpServletResponse response
public void setLog(Log log)
public void setRequest(HttpServletRequest request)
HttpServletRequest
. This is required
for this tool to operate and will throw a NullPointerException
if this is not set or is set to null
.public void setResponse(HttpServletResponse response)
HttpServletResponse
. This is required
for this tool to operate and will throw a NullPointerException
if this is not set or is set to null
.public void setServletContext(ServletContext application)
ServletContext
. This is required
for this tool to operate and will throw a NullPointerException
if this is not set or is set to null
.protected java.lang.String acquireString(java.lang.String url) throws java.io.IOException, java.lang.Exception
url
- the URL resource to return as stringjava.io.IOException
java.lang.Exception
protected java.io.Reader acquireReader(java.lang.String url) throws java.io.IOException, java.lang.Exception
url
- the URL to readjava.io.IOException
java.lang.Exception
public static boolean isAbsoluteUrl(java.lang.String url)
url
- the url to check outpublic static java.lang.String stripSession(java.lang.String url)
url
- the url to strip the session id frompublic static java.lang.String getContentTypeAttribute(java.lang.String input, java.lang.String name)
input
- the string containing the attributesname
- the name of the content-type attributeCopyright (c) 2003-2007 Apache Software Foundation