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