tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Smith <d...@cornell.edu>
Subject Re: How to refer to file?
Date Mon, 18 May 2009 12:51:28 GMT
Dola Woolfe wrote:
> Hi,
>
> Within a .jsp document, is there a way of referring to a file in same directory?
>
> For example, new java.io.File(ThisDir, "FileName.txt").
>
> Thanks,
>
> Dola
>
>
>       
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>   
There aren't any API calls to do that directly.  Provided the jsp is
being directly called from the client, you could use
request.getServletPath() to get the path to the jsp and use that to
compute a webapp relative path to the file you want.  Then use something
like pageContext.getServletContext.getResourceAsStream(myfilepath.txt)
to open the file for read.

--David


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message