tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kenneth Jensen <xml...@gmail.com>
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 +
getInitParameter("keystorefile");

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

Thanks,
Kenneth

On 5/27/05, Peter Crowther <Peter.Crowther@melandra.com> wrote:
> > From: Kenneth Jensen [mailto:xmlsec@gmail.com]
> > 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.
> 
> http://java.sun.com/j2ee/sdk_1.3/techdocs/api/javax/servlet/ServletConte
> xt.html#getResource(java.lang.String)
> 
>                 - Peter
> 


-- 
---
Cheers,
Kenneth

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


Mime
View raw message