org.springframework.web.context.support
Class ServletContextResource

org.springframework.core.io.AbstractResource
  |
  +--org.springframework.web.context.support.ServletContextResource

public class ServletContextResource
extends AbstractResource

Resource implementation for ServletContext resources, interpreting relative paths within the web application root.

Always supports stream access, but only allows java.io.File access when the web application archive is expanded.

Author:
Juergen Hoeller
Since: 28.12.2003
See Also: javax.servlet.ServletContext#getResourceAsStream, javax.servlet.ServletContext#getRealPath

Constructor Summary
ServletContextResource(ServletContext servletContext, String path)
          Create a new ServletContextResource.

Method Summary
 StringgetDescription()
           
 FilegetFile()
          This implementation delegates to ServletContext.getRealPath, but throws a FileNotFoundException if not found or not resolvable.
 InputStreamgetInputStream()
          This implementation delegates to ServletContext.getResourceAsStream, but throws a FileNotFoundException if not found.

Methods inherited from class org.springframework.core.io.AbstractResource
equals, exists, hashCode, isOpen, toString

Constructor Detail

ServletContextResource

public ServletContextResource(ServletContext servletContext, String path)
Create a new ServletContextResource.
Parameters:
servletContext - the ServletContext to load from
path - the path of the resource
Method Detail

getDescription

public String getDescription()

getFile

public File getFile()
throws java.io.IOException
This implementation delegates to ServletContext.getRealPath, but throws a FileNotFoundException if not found or not resolvable.
See Also:
javax.servlet.ServletContext#getRealPath

getInputStream

public InputStream getInputStream()
throws java.io.IOException
This implementation delegates to ServletContext.getResourceAsStream, but throws a FileNotFoundException if not found.
See Also:
javax.servlet.ServletContext#getResourceAsStream

Association Links

to Class java.lang.String