on 02-17-2006 5:42 AM
Hi
I have a servlet and it calls some classes which are kept in a jar file in WEB-INF/lib directory. With in one of the classes there is a IO file read happening. How should i read the file and what path should i put if the file is in WEB-INF/resources
my jar files are in web-inf/lib directory. How will i read the file and what should be the patch to be given
regards,
Sujesh
Hi,
Check this out
FileInputStream fis = new FileInputStream(new File("..
resources
filenmae"));
.. refers to parent directory ( in your case it is WEB-INF ).
Regards,
Uma
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I have a servlet which calls a class. The class inturn reads an xml file which is kept inside web-inf, inside web-inf/lib, and the class's folder. Iam trying to read the file using
InputStream isStream = this.getClass().getClassLoader().getResourseAsStream("config.xml")
isStream is coming as null...how will i read it.I made ear file and deployed in was 6.4 sp11
Any suggestions??
Hi Sujesh,
you can use getResource(path) or getResourceAsStream, see http://java.sun.com/j2ee/sdk_1.3/techdocs/api/javax/servlet/ServletContext.html
See http://www.slamb.org/projects/axamol/sql-library/manual/ch01s03.html for an example.
Hope it helps
Detlev
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
88 | |
10 | |
10 | |
9 | |
6 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.