tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kenneth Jensen <>
Subject Re: How to read a file on disk from a servlet
Date Fri, 27 May 2005 13:49:02 GMT
Thanks for both of your advices.

JNDI is probably the smart way of doing it, but I am not familiar with
it (beyond recognising the name and concept), and right now, the last
thing I need is another tech thing to worry about (finishing a student
project). :-)

The ServletContext.getResource depends on a URL string from the
request, as far as I can see, and I could not get it to work quickly,
so I ended up wth this rather silly hack in the servlet init() method:

ServletContext context = getServletConfig().getServletContext();
String slash = System.getProperty("file.separator");
keystore = context.getRealPath("/") + "WEB-INF" + slash +

That way, I just have to know the relative path to the webapps WEB-INF dir.


On 5/27/05, Peter Crowther <> wrote:
> > From: Kenneth Jensen []
> > How do I get my servlet to read the keystore file, say if I put it in
> > $CATAILNA_HOME/webapps/<mywebapp>/WEB-INF/lib/mykeystore.jks.
> xt.html#getResource(java.lang.String)
>                 - Peter


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message