public abstract class ImportSupport extends 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 javax.servlet.ServletContext |
application |
protected static String |
DEFAULT_ENCODING
Default character encoding for response.
|
protected org.apache.velocity.runtime.log.Log |
LOG |
protected javax.servlet.http.HttpServletRequest |
request |
protected javax.servlet.http.HttpServletResponse |
response |
protected static String |
VALID_SCHEME_CHARS |
Constructor and Description |
---|
ImportSupport() |
Modifier and Type | Method and Description |
---|---|
protected Reader |
acquireReader(String url) |
protected String |
acquireString(String url) |
static String |
getContentTypeAttribute(String input,
String name)
Get the value associated with a content-type attribute.
|
static boolean |
isAbsoluteUrl(String url)
Returns true if our current URL is absolute,
false otherwise.
|
void |
setLog(org.apache.velocity.runtime.log.Log log) |
void |
setRequest(javax.servlet.http.HttpServletRequest request)
Sets the current
HttpServletRequest . |
void |
setResponse(javax.servlet.http.HttpServletResponse response)
Sets the current
HttpServletResponse . |
void |
setServletContext(javax.servlet.ServletContext application)
Sets the
ServletContext . |
static String |
stripSession(String url)
Strips a servlet session ID from url.
|
protected static final String VALID_SCHEME_CHARS
protected static final String DEFAULT_ENCODING
protected org.apache.velocity.runtime.log.Log LOG
protected javax.servlet.ServletContext application
protected javax.servlet.http.HttpServletRequest request
protected javax.servlet.http.HttpServletResponse response
public void setLog(org.apache.velocity.runtime.log.Log log)
public void setRequest(javax.servlet.http.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(javax.servlet.http.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(javax.servlet.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 String acquireString(String url) throws IOException, Exception
url
- the URL resource to return as stringIOException
Exception
protected Reader acquireReader(String url) throws IOException, Exception
url
- the URL to readIOException
Exception
public static boolean isAbsoluteUrl(String url)
url
- the url to check outpublic static String stripSession(String url)
url
- the url to strip the session id frompublic static String getContentTypeAttribute(String input, String name)
input
- the string containing the attributesname
- the name of the content-type attributeCopyright © 2002–2021 Apache Software Foundation. All rights reserved.