SRV.4.4 Resources


The ServletContext interface allows direct access to the static document hierarchy of content documents, such as HTML, GIF, and JPEG files, that are part of the web application via the following methods of the ServletContext interface:

  • getResource

  • getResourceAsStream

Both the getResource and getResourceAsStream methods take a String argument giving the path of the resource relative to the root of the context.

It is important to note that these methods give access to static resources from whatever repository the server uses. This hierarchy of documents may exist in a 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 Pages specification, [1] 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.

[1] See the JavaServer Pages specification, Section JSP, in this volume.



Java 2 Platform, Enterprise Edition. Platform and Component Specifications
Java 2 Platform, Enterprise Edition: Platform and Component Specifications
ISBN: 0201704560
EAN: 2147483647
Year: 2000
Pages: 399

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net