au.com.lastweekend.servlet
Class ServletContextResource

java.lang.Object
  extended by au.com.lastweekend.servlet.ServletContextResource

public class ServletContextResource
extends java.lang.Object

Common resource locator for our servlets and filters that may not be rooted at the realPath of the servletContext.

Determine a resourceBase path from a ServletConfig or FilterConfig by trying the following

  • initParam - "resourceBase"
  • contextParam - "au.com.lastweekend.servlet.resourceBase"
  • servletContext.getRealPath("/")
  • An empty initParam can be used to override a contextParam setting to return to the container's getRealPath implementation.

    Version:
    $Id$
    Author:
    Grant Gardner grant@lastweekend.com.au

    Field Summary
    static java.lang.String CONTEXT_PARAM_RESOURCE_BASE
              Common context-param for assigning a resourceBase in the file system to all the servlets/filters that find resources in the web app and need to be aligned.
    static java.lang.String INIT_PARAM_RESOURCE_BASE
              init param name for filter/servlets to override context-param or container.
     
    Constructor Summary
    ServletContextResource(javax.servlet.FilterConfig config)
               
    ServletContextResource(javax.servlet.ServletConfig config)
               
     
    Method Summary
     java.net.URL getAbsoluteResource(java.lang.String absolutePath)
              Utility to test the existance of a file path.
     java.lang.String getRealPath(java.lang.String resourcePath)
               
     java.net.URL getResource(java.lang.String resourcePath)
               
     
    Methods inherited from class java.lang.Object
    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
     

    Field Detail

    INIT_PARAM_RESOURCE_BASE

    public static final java.lang.String INIT_PARAM_RESOURCE_BASE
    init param name for filter/servlets to override context-param or container. An empty value will override a context-param in favour of the container implementation.

    Value: "resourceBase"

    See Also:
    Constant Field Values

    CONTEXT_PARAM_RESOURCE_BASE

    public static final java.lang.String CONTEXT_PARAM_RESOURCE_BASE
    Common context-param for assigning a resourceBase in the file system to all the servlets/filters that find resources in the web app and need to be aligned.

    Value: "au.com.lastweekend.servlet.resourceBase"

    See Also:
    Constant Field Values
    Constructor Detail

    ServletContextResource

    public ServletContextResource(javax.servlet.FilterConfig config)

    ServletContextResource

    public ServletContextResource(javax.servlet.ServletConfig config)
    Method Detail

    getResource

    public java.net.URL getResource(java.lang.String resourcePath)

    getRealPath

    public java.lang.String getRealPath(java.lang.String resourcePath)

    getAbsoluteResource

    public java.net.URL getAbsoluteResource(java.lang.String absolutePath)
    Utility to test the existance of a file path.

    Parameters:
    absolutePath -
    Returns:
    a canonical File URL for the absolutePath if it exists, null otherwise.


    Copyright © 2008. All Rights Reserved.