On Fri, 2 Mar 2001, Kevin Sangeelee wrote:

> On Thu, 1 Mar 2001, Brett G. Palmer wrote:
> 
> > What is the best way to read a file from a Context in Tomcat?  I know I can
> > get the context path from the "getContextPath()" method, but most file
> > stream APIs require a full path.  There most be a clean way to accomplish
> > this without hard coding any directory path info.
> 
> I've used the following in the past, where s is a ServletConfig object
> 
>       ServletContext sc = s.getServletContext();
>       String fullPath = sc.getRealPath("") + "WEB-INF/myfiles/xyz.dat"

Wouldn't getResource() (or getResourceAsStream()) be the way to go
with this?

Milt Epstein
Research Programmer
Software/Systems Development Group
Computing and Communications Services Office (CCSO)
University of Illinois at Urbana-Champaign (UIUC)
[EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, email: [EMAIL PROTECTED]

Reply via email to