Class ViewImportSupport
java.lang.Object
org.apache.velocity.tools.generic.SafeConfig
org.apache.velocity.tools.generic.ImportSupport
org.apache.velocity.tools.view.ViewImportSupport
public class ViewImportSupport
extends org.apache.velocity.tools.generic.ImportSupport
Provides methods to import arbitrary local or remote resources as strings.
Based on ImportSupport from the JSTL taglib by Shawn Bayern
- Since:
- VelocityTools 3.0
- Version:
- $Revision$ $Date$
- Author:
- Marino A. Jonsson, Claude Brisson
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static classWraps responses to allow us to retrieve results as Strings.protected static class -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected javax.servlet.ServletContextprotected javax.servlet.http.HttpServletRequestprotected javax.servlet.http.HttpServletResponseFields inherited from class org.apache.velocity.tools.generic.ImportSupport
RESOURCE_KEY, URL_KEY, VALID_SCHEME_CHARSFields inherited from class org.apache.velocity.tools.generic.SafeConfig
LOCK_CONFIG_KEY, log, LOGGER_NAME_KEY, SAFE_MODE_KEY, USE_CLASS_LOGGER_KEY -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected Readerprotected Stringprotected Readerprotected Stringprotected voidconfigure(org.apache.velocity.tools.generic.ValueParser values) protected URLgetFileResource(String resource) protected StringmergeQueryStrings(String url) Merge original parameters into the query stringvoidsetRequest(javax.servlet.http.HttpServletRequest request) Sets the currentHttpServletRequest.voidsetResponse(javax.servlet.http.HttpServletResponse response) Sets the currentHttpServletResponse.voidsetServletContext(javax.servlet.ServletContext application) Sets theServletContext.static StringstripSession(String url) Strips a servlet session ID from url.Methods inherited from class org.apache.velocity.tools.generic.ImportSupport
acquireReader, acquireString, getClasspathResource, getContentTypeAttribute, getProtocol, getResourceReader, getResourceString, isRemoteURL, setSafeModeMethods inherited from class org.apache.velocity.tools.generic.SafeConfig
configure, getLog, initLogger, isConfigLocked, isSafeMode, setLockConfig
-
Field Details
-
application
protected javax.servlet.ServletContext application -
request
protected javax.servlet.http.HttpServletRequest request -
response
protected javax.servlet.http.HttpServletResponse response
-
-
Constructor Details
-
ViewImportSupport
public ViewImportSupport()
-
-
Method Details
-
configure
protected void configure(org.apache.velocity.tools.generic.ValueParser values) - Overrides:
configurein classorg.apache.velocity.tools.generic.ImportSupport
-
setRequest
public void setRequest(javax.servlet.http.HttpServletRequest request) Sets the currentHttpServletRequest. This is required for this tool to operate and will throw a NullPointerException if this is not set or is set tonull.- Parameters:
request- servlet request
-
setResponse
public void setResponse(javax.servlet.http.HttpServletResponse response) Sets the currentHttpServletResponse. This is required for this tool to operate and will throw a NullPointerException if this is not set or is set tonull.- Parameters:
response- servlet response
-
setServletContext
public void setServletContext(javax.servlet.ServletContext application) Sets theServletContext. This is required for this tool to operate and will throw a NullPointerException if this is not set or is set tonull.- Parameters:
application- servlet context
-
acquireRemoteURLString
- Overrides:
acquireRemoteURLStringin classorg.apache.velocity.tools.generic.ImportSupport- Parameters:
url- the remote URL resource to return as string- Returns:
- the URL resource as string
- Throws:
IOException- if thrown by underlying code
-
acquireLocalURLString
- Overrides:
acquireLocalURLStringin classorg.apache.velocity.tools.generic.ImportSupport- Parameters:
url- the local URL resource to return as string- Returns:
- the URL resource as string
- Throws:
IOException- if not allowed or if thrown by underlying code
-
acquireRemoteURLReader
- Overrides:
acquireRemoteURLReaderin classorg.apache.velocity.tools.generic.ImportSupport- Parameters:
url- the URL to read- Returns:
- a Reader for the InputStream created from the supplied URL
- Throws:
IOException- if not allowed or thrown by underlying code
-
acquireLocalURLReader
- Overrides:
acquireLocalURLReaderin classorg.apache.velocity.tools.generic.ImportSupport- Parameters:
url- the URL to read- Returns:
- a Reader for the InputStream created from the supplied URL
- Throws:
IOException- if thrown by underlying code
-
stripSession
Strips a servlet session ID from url. The session ID is encoded as a URL "path parameter" beginning with "jsessionid=". We thus remove anything we find between ";jsessionid=" (inclusive) and either EOS or a subsequent ';' (exclusive).- Parameters:
url- the url to strip the session id from- Returns:
- the stripped url
-
mergeQueryStrings
-
getFileResource
-