|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjavax.servlet.GenericServlet
javax.servlet.http.HttpServlet
org.hippoecm.hst.servlet.ResourceServlet
public class ResourceServlet
Serves resources from either web application or classpath.
A typical configuration is to set classpath resource path and map a servlet path to this servlet.ExampleResourceServlet
,
which reads the target resource from the configured classpath resource path, "/META-INF/example/myapp/skin".
For example, if the request path info is "/myapp/skin/example.png", then the servlet will find the corresponding
classpath resource, "classpath:META-INF/example/myapp/skin/example.png", to serve the request.
The following init parameters are available:
Init parameter name | Description | Example value | Default value |
---|---|---|---|
jarPathPrefix | Classpath resource path prefix | META-INF/example/myapp/skin | META-INF |
cacheTimeout | Millisecond value to set cache control HTTP headers: 'Expires' and 'Cache-Control'. These cache control HTTP headers will be written only if this value is greater than zero. Otherwise, the cache control HTTP headers are not written. | 0 | 31556926 |
gzipEnabled | Flag to enable/disable gzip encoded response for specified mimeTypes, which can be configured by 'compressedMimeTypes' init parameter. | false | true |
webResourceEnabled | Flag to enable/disable to read resources from the servlet context on web application resources. If this is enabled, then the servlet will try to read a resource from the web application first by the request path info. | false | true |
jarResourceEnabled | Flag to enable/disable to read resources from the classpath resources. If this is enabled, then the servlet will try to read a resource from the classpath. | false | true |
allowedResourcePaths | Sets resource path regex patterns which are allowed to serve by this servlet. | ^/.\*\.js, ^/.\*\.css, ^/.\*\.png, ^/.\*\.gif, ^/.\*\.ico, ^/.\*\.jpg, ^/.\*\.jpeg, ^/.\*\.swf, ^/.\*\.txt |
^/.\*\.js, ^/.\*\.css, ^/.\*\.png, ^/.\*\.gif, ^/.\*\.ico, ^/.\*\.jpg, ^/.\*\.jpeg, ^/.\*\.swf |
mimeTypes | Sets mimeType mappings to override (or add) from the default mimeType mappings of the web application. If a proper mimeType is not found by this mapping, then it will look up a mimeType from the web application. | .css = text/css, .js = text/javascript, .gif = image/gif, .png = image/png, .ico = image/vnd.microsoft.icon, .jpg = image/jpeg, .jpeg = image/jpeg, .swf = application/x-shockwave-flash, .txt = text/plain |
.css = text/css, .js = text/javascript, .gif = image/gif, .png = image/png, .ico = image/vnd.microsoft.icon, .jpg = image/jpeg, .jpeg = image/jpeg, .swf = application/x-shockwave-flash |
compressedMimeTypes | Sets mimeTypes which can be compressed to serve the resource by this servlet. If a resource is in this kind of mimeTypes, then the servlet will write a compressed response in gzip encoding. | text/.*, application/json |
text/.* |
Constructor Summary | |
---|---|
ResourceServlet()
|
Method Summary | |
---|---|
protected void |
doGet(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
|
void |
init()
|
Methods inherited from class javax.servlet.http.HttpServlet |
---|
doDelete, doHead, doOptions, doPost, doPut, doTrace, getLastModified, service, service |
Methods inherited from class javax.servlet.GenericServlet |
---|
destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, log, log |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ResourceServlet()
Method Detail |
---|
public void init() throws javax.servlet.ServletException
init
in class javax.servlet.GenericServlet
javax.servlet.ServletException
protected void doGet(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException, IOException
doGet
in class javax.servlet.http.HttpServlet
javax.servlet.ServletException
IOException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |