> I'm not sure whether it's possible to access something in
> WEB-INF using getResourceAsStream.
>

 Yes, it is possible, the servlet spec[1] allows for it
explicitly:

  SRV.9.5 "Directory Structure"

  ... No file contained in the WEB-INF directory may
  be served directly to a client by the container.
  However, the contents of the WEB-INF directory are
  visible to servlet code using the getResource and
  getResourceAsStream method calls on the
  ServletContext. ...


> As for the original question: what is the result you are
> trying to obtain? Can't you just use a FileReader to obtain
> the same result: new FileReader("/WEB-INF/Test.txt");
>

 Using FileReader isn't such a good idea, since some
servlet containers (like MinTC[2]), will run webapps
directly from the war instead of expanding them out
into the filesystem. If there's no filesystem, then
FileReader won't work. The getResource*() methods are
the right way to access your local webapp "files".


[EMAIL PROTECTED] wrote:
>
> Ronald Wildenberg <[EMAIL PROTECTED]> wrote:
>
> > You can get a character stream (= Reader) by using
> > java.io.InputStreamReader.
>
> But still I am getting the same result
>
> while((ch = ir.read())!= -1)
>   System.out.print(ch);
>

 It looks like you didn't post real code, so it's hard
to tell. If "ch" is an int, then try

  System.out.print((char)ch);

otherwise you need to say what you mean by "the same
result"


[1] http://java.sun.com/products/servlet/download.html
[2] http://www.distributopia.com/mintc/


--
Christopher St. John [EMAIL PROTECTED]
DistribuTopia http://www.distributopia.com

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to