472,352 Members | 1,558 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,352 software developers and data experts.

Servlet reading config file from ?? path

I have a web application that needs to read an xml configuration file. How
can I specify this without knowing the path of the web application?

I've tried using ClassLoader.getSystemResourceAsStream(filename) but this
doesn't seem to work for my servlet even with the config file in the lib
folder of the web app.

Can anyone give me any pointers?
Jul 17 '05 #1
3 12265
"Moth" <no*@this.address> wrote in message news:<ge******************@news-server.bigpond.net.au>...
I have a web application that needs to read an xml configuration file. How
can I specify this without knowing the path of the web application?

I've tried using ClassLoader.getSystemResourceAsStream(filename) but this
doesn't seem to work for my servlet even with the config file in the lib
folder of the web app.

Can anyone give me any pointers?


I believe any configuration item can be written in WEBINF/web.xml file
and can be read via standard Servlet API methods.
Jul 17 '05 #2


"hiwa" <HG******@nifty.ne.jp> wrote in message
news:68**************************@posting.google.c om...
"Moth" <no*@this.address> wrote in message

news:<ge******************@news-server.bigpond.net.au>...
I have a web application that needs to read an xml configuration file. How can I specify this without knowing the path of the web application?

I've tried using ClassLoader.getSystemResourceAsStream(filename) but this doesn't seem to work for my servlet even with the config file in the lib
folder of the web app.

Can anyone give me any pointers?


I believe any configuration item can be written in WEBINF/web.xml file
and can be read via standard Servlet API methods.


getClass().getResource("/path/from/app/root/to/file.xml")

--
Tony Morris
(BInfTech, Cert 3 I.T., SCJP[1.4], SCJD)
Software Engineer
IBM Australia - Tivoli Security Software
(2003 VTR1000F)
Jul 17 '05 #3
"Moth" <no*@this.address> wrote in message news:<ge******************@news-server.bigpond.net.au>...
I have a web application that needs to read an xml configuration file. How
can I specify this without knowing the path of the web application?

I've tried using ClassLoader.getSystemResourceAsStream(filename) but this
doesn't seem to work for my servlet even with the config file in the lib
folder of the web app.

Can anyone give me any pointers?


I do not know if you are using Tomcat, but if you are I think you
should try to put the file in the /WEB-INF/classes directory of your
application. In this directory you should put classes and resources
that are unpacked. Classes and resources in jar-files should be put in
the /WEB-INF/lib. Classes and resources that are put in these
directories are visible only to the containing web application, but to
no others.
Jul 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Ric | last post by:
thx for the help. im having problems with java and jsp. i think im not settup up the enviornmental variables right in w2k advanced tab. im using a...
1
by: Vasil Slavov | last post by:
I apologize for the long email. I hope somebody will have time to read it and give some suggestions. I am working on a school project written in...
1
by: Srini | last post by:
Hi everyone, I want to transfer a file from servlet page or JSP to an ASP page. Since the two pages are in different server (WAS and IIS), I...
3
by: Christofer Dutz | last post by:
Hi, I am thinking about migrating an application of mine to .Net and have run into this small "problem" At the moment I would generally compare...
0
by: androusm | last post by:
Hi all, I have a problem with reload my servlet with tomcat 5.0.27 My servlet is the one example of the struts "struts-example". I also make...
0
by: mak1084 | last post by:
hi folks, i installed tomcat 5.5... and there was already jdk 1.5.0.02 was installed. i cofigure the path JAVA_HOME and CLASSPATH corectly but i'm...
1
by: shyaminf | last post by:
hi everybody! iam facing a problem with the transfer of file using servlet programming. i have a code for uploading a file. but i'm unable to...
3
by: krishna81m | last post by:
Hello, I am looking for a solution to update a .jsp page (kind of progress bar) which shows current progress in a huge simulation when users have...
9
by: mjahabarsadiq | last post by:
Hi I have created a servlet that is to be started at the server startup. And I got it. In that I have created a object of another class and set...
0
better678
by: better678 | last post by:
Question: Discuss your understanding of the Java platform. Is the statement "Java is interpreted" correct? Answer: Java is an object-oriented...
0
by: teenabhardwaj | last post by:
How would one discover a valid source for learning news, comfort, and help for engineering designs? Covering through piles of books takes a lot of...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was...
0
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. ...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific...
0
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.