Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.struts2.dispatcher
Class DefaultStaticContentLoader

    java.lang.Object
      org.apache.struts2.dispatcher.DefaultStaticContentLoader

All Implemented Interfaces:
  StaticContentLoader

    public class DefaultStaticContentLoader

extends java.lang.Object
implements StaticContentLoader

Field Summary
`protected java.lang.String` | `encoding` Store state of StrutsConstants.STRUTS_I18N_ENCODING setting.
`protected java.util.Calendar` | `lastModifiedCal` Provide a formatted date for setting heading information when caching static content.
`protected java.lang.String[]` | `pathPrefixes` Store set of path prefixes to use with static resources.
`protected boolean` | `serveStatic` Store state of StrutsConstants.STRUTS_SERVE_STATIC_CONTENT setting.
`protected boolean` | `serveStaticBrowserCache` Store state of StrutsConstants.STRUTS_SERVE_STATIC_BROWSER_CACHE setting.

Constructor Summary
`DefaultStaticContentLoader()`

Method Summary
`protected java.lang.String` | `buildPath(java.lang.String name, java.lang.String packagePrefix)`
`boolean` | `canHandle(java.lang.String resourcePath)`
`protected java.lang.String` | `cleanupPath(java.lang.String path)`
`protected void` | `copy(java.io.InputStream input, java.io.OutputStream output)` Copy bytes from the input stream to the output stream.
`protected java.net.URL` | `findResource(java.lang.String path)` Look for a static resource in the classpath.
`void` | `findStaticResource(java.lang.String path, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)` Locate a static resource and copy directly to the response, setting the appropriate caching headers.
`protected java.lang.String` | `getAdditionalPackages()`
`protected java.lang.String` | `getContentType(java.lang.String name)` Determine the content type for the resource name.
`protected java.lang.String[]` | `parse(java.lang.String packages)` Create a string array from a comma-delimited list of packages.
`protected void` | `process(java.io.InputStream is, java.lang.String path, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)`
`void` | `setEncoding(java.lang.String val)` Modify state of StrutsConstants.STRUTS_I18N_ENCODING setting.
`void` | `setHostConfig(HostConfig filterConfig)`
`void` | `setServeStaticBrowserCache(java.lang.String val)` Modify state of StrutsConstants.STRUTS_SERVE_STATIC_BROWSER_CACHE setting.
`void` | `setServeStaticContent(java.lang.String val)` Modify state of StrutsConstants.STRUTS_SERVE_STATIC_CONTENT setting.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### pathPrefixes

    protected java.lang.String[] pathPrefixes

  Store set of path prefixes to use with static resources.

### serveStatic

    protected boolean serveStatic

  Store state of StrutsConstants.STRUTS_SERVE_STATIC_CONTENT setting.

### serveStaticBrowserCache

    protected boolean serveStaticBrowserCache

  Store state of StrutsConstants.STRUTS_SERVE_STATIC_BROWSER_CACHE setting.

### lastModifiedCal

    protected final java.util.Calendar lastModifiedCal

  Provide a formatted date for setting heading information when caching static content.

### encoding

    protected java.lang.String encoding

  Store state of StrutsConstants.STRUTS_I18N_ENCODING setting.

Constructor Detail

### DefaultStaticContentLoader

    public DefaultStaticContentLoader()

Method Detail

### setServeStaticContent

    public void setServeStaticContent(java.lang.String val)

  Modify state of StrutsConstants.STRUTS_SERVE_STATIC_CONTENT setting.

  Parameters:
    `val` - New setting

### setServeStaticBrowserCache

    public void setServeStaticBrowserCache(java.lang.String val)

  Modify state of StrutsConstants.STRUTS_SERVE_STATIC_BROWSER_CACHE setting.

  Parameters:
    `val` - New setting

### setEncoding

    public void setEncoding(java.lang.String val)

  Modify state of StrutsConstants.STRUTS_I18N_ENCODING setting.

  Parameters:
    `val` - New setting

### setHostConfig

    public void setHostConfig(HostConfig filterConfig)

  Specified by:
    `setHostConfig` in interface `StaticContentLoader`
  Parameters:
    `filterConfig` - The filter configuration

### getAdditionalPackages

    protected java.lang.String getAdditionalPackages()

### parse

    protected java.lang.String[] parse(java.lang.String packages)

  Create a string array from a comma-delimited list of packages.

  Parameters:
    `packages` - A comma-delimited String listing packages
  Returns:
    A string array of packages

### findStaticResource

    public void findStaticResource(java.lang.String path,
                                   javax.servlet.http.HttpServletRequest request,
                                   javax.servlet.http.HttpServletResponse response)
                            throws java.io.IOException

  Description copied from interface: `StaticContentLoader`
  Locate a static resource and copy directly to the response, setting the appropriate caching headers.

  Specified by:
    `findStaticResource` in interface `StaticContentLoader`
  Parameters:
    `path` - The resource name
    `request` - The request
    `response` - The response
  Throws:
    `java.io.IOException` - If anything goes wrong

### process

    protected void process(java.io.InputStream is,
                           java.lang.String path,
                           javax.servlet.http.HttpServletRequest request,
                           javax.servlet.http.HttpServletResponse response)
                    throws java.io.IOException

  Throws:
    `java.io.IOException`

### findResource

    protected java.net.URL findResource(java.lang.String path)
                                 throws java.io.IOException

  Look for a static resource in the classpath.

  Parameters:
    `path` - The resource path
  Returns:
    The inputstream of the resource
  Throws:
    `java.io.IOException` - If there is a problem locating the resource

### buildPath

    protected java.lang.String buildPath(java.lang.String name,
                                         java.lang.String packagePrefix)
                                  throws java.io.UnsupportedEncodingException

  Parameters:
    `name` - resource name
    `packagePrefix` - The package prefix to use to locate the resource
  Returns:
    full path
  Throws:
    `java.io.UnsupportedEncodingException`
    `java.io.IOException`

### getContentType

    protected java.lang.String getContentType(java.lang.String name)

  Determine the content type for the resource name.

  Parameters:
    `name` - The resource name
  Returns:
    The mime type

### copy

    protected void copy(java.io.InputStream input,
                        java.io.OutputStream output)
                 throws java.io.IOException

  Copy bytes from the input stream to the output stream.

  Parameters:
    `input` - The input stream
    `output` - The output stream
  Throws:
    `java.io.IOException` - If anything goes wrong

### canHandle

    public boolean canHandle(java.lang.String resourcePath)

  Specified by:
    `canHandle` in interface `StaticContentLoader`
  Parameters:
    `resourcePath` - Requested resource path
  Returns:
    true if this loader is able to load this type of resource, false otherwise

### cleanupPath

    protected java.lang.String cleanupPath(java.lang.String path)

  Parameters:
    `path` - requested path
  Returns:
    path without leading "/struts" or "/static"

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2000-2011 Apache Software Foundation. All Rights Reserved.