Re: Progmatically retriving files in WEB-INF

2001-06-29 Thread Bo Xu

Christopher Kirk wrote:

> [...]
> InputStream inputStream
> = getServletConfig().getServletContext().getResourceAsStream("me.txt");
>
> if (inputStream == null) {
>   System.out.println("NULL");
> } else {
>  System.out.println("NOT NULL");
> }
>   }
> }
>
> However, inputStream is always null!   Am I approaching this the wrong way,
> or is this a bug in Tomcat?  (I have searched the bug database and failed to
> find anything so I suspect my understanding of the Servlet spec is faulty).
>
> I thought that the ServletContext object was used to access the WEB-INF
> directory.. ?
> [...]

Hi :-)  I suggest you try the following:  the "path" is from "myapp/" ,
not from "myapp/WEB-INF/"


- InputStream is = getServletContext().
 getResourceAsStream("/WEB-INF/me.txt");

or

- InputStream is = getServletConfig().getServletContext().
 getResourceAsStream("/WEB-INF/me.txt");



Bo
June 29, 2001






Antw: Progmatically retriving files in WEB-INF(Abwesenheitsnotiz)

2001-06-29 Thread Petra Hora

Ich bin bis 9.7.2001 auf Urlaub. Bitte wenden Sie sich in dieser Zeit an meine 
Kollegen im Team EW2

Mit freundlichen Grüßen 
Petra Hora



Progmatically retriving files in WEB-INF

2001-06-29 Thread Christopher Kirk


Hopefully somebody could point out where I am going wrong...


I am using WAR deployment under Tomcat3.2.1 on a WinNT4 box.

I have placed a file (me.txt) in the WEB-INF directory, and have written the
following servlet which tries to read the file.


public class MercuryServlet extends HttpServlet{
  public void init() throws ServletException {

InputStream inputStream
= getServletConfig().getServletContext().getResourceAsStream("me.txt");

if (inputStream == null) {
  System.out.println("NULL");
} else {
 System.out.println("NOT NULL");
}
  }
}


However, inputStream is always null!   Am I approaching this the wrong way,
or is this a bug in Tomcat?  (I have searched the bug database and failed to
find anything so I suspect my understanding of the Servlet spec is faulty).

I thought that the ServletContext object was used to access the WEB-INF
directory.. ?


Thanx in advance,

- Chris.


--

NOTICE:  The information contained in this electronic mail transmission is
intended by Convergys Corporation for the use of the named individual or
entity to which it is directed and may contain information that is
privileged or otherwise confidential.  If you have received this electronic
mail transmission in error, please delete it from your system without
copying or forwarding it, and notify the sender of the error by reply email
or by telephone (collect), so that the sender's address records can be
corrected.