aspose file tools*
The moose likes Servlets and the fly likes ServletContext Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "ServletContext" Watch "ServletContext" New topic
Author

ServletContext

MInu
Ranch Hand

Joined: Oct 09, 2003
Posts: 517
Hi...

Can anyone give me the detailed explanation of

' getResourceAsStream(java.lang.String path) ' method?

How to call this method?

Thanks.


God Gave Me Nothing I Wanted<br />He Gave Me Everything I Needed<br /> - Swami Vivekananda
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

From the API:

--------------------------------------------------------------------------------

getResourceAsStream
public java.io.InputStream getResourceAsStream(java.lang.String path)Returns the resource located at the named path as an InputStream object.
The data in the InputStream can be of any type or length. The path must be specified according to the rules given in getResource. This method returns null if no resource exists at the specified path.

Meta-information such as content length and content type that is available via getResource method is lost when using this method.

The servlet container must implement the URL handlers and URLConnection objects necessary to access the resource.

This method is different from java.lang.Class.getResourceAsStream, which uses a class loader. This method allows servlet containers to make a resource available to a servlet from any location, without using a class loader.

Parameters:
path - a String specifying the path to the resource
Returns:
the InputStream returned to the servlet, or null if no resource exists at the specified path

--------------------------------------------------------------------------------
sawan parihar
Ranch Hand

Joined: Aug 24, 2004
Posts: 250
Hi,
Given a path it will return you InputStream. It is same as getResource().openStream().

cheers


Sawan<br />SCJP,SCWCD,SCBCD<br /> <br />Every exit is an entry somewhere.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: ServletContext