Resources
The ServletContext interface provides direct access only to the hierarchy of static content documents that are part of the Web application, including HTML, GIF, and JPEG files, via the following methods of the ServletContext interface:
=> getResource
=> getResourceAsStream
The getResource and getResourceAsStream methods take a String with a leading “/” as an argument that gives the path of the resource relative to the root of the context. This hierarchy of documents may exist in the server’s file system, in a Web application archive file, on a remote server, or at some other location.
These methods are not used to obtain dynamic content. For example, in a container supporting the JavaServer PagesTM specification1, a method call of the form getResource("/index.jsp") would return the JSP source code and not the processed output. See Chapter SRV.8, “Dispatching Requests” for more information about accessing dynamic content.
The full listing of the resources in the Web application can be accessed using the getResourcePaths(String path) method. The full details on the semantics of this method may be found in the API documentation in this specification.
=> getResource
=> getResourceAsStream
The getResource and getResourceAsStream methods take a String with a leading “/” as an argument that gives the path of the resource relative to the root of the context. This hierarchy of documents may exist in the server’s file system, in a Web application archive file, on a remote server, or at some other location.
These methods are not used to obtain dynamic content. For example, in a container supporting the JavaServer PagesTM specification1, a method call of the form getResource("/index.jsp") would return the JSP source code and not the processed output. See Chapter SRV.8, “Dispatching Requests” for more information about accessing dynamic content.
The full listing of the resources in the Web application can be accessed using the getResourcePaths(String path) method. The full details on the semantics of this method may be found in the API documentation in this specification.
No comments:
Post a Comment