473,378 Members | 1,351 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 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 12331
"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 wrox book, but the wrox book references a servlet...
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 Python (using mod_python) and I need to upload a...
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 cannot just send file path to the ASP page and let it...
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 ASP.Net to JSPs in the Java world. I know that...
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 changes and want to reload it by tomcat 5.0.27. ...
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 not able to compile servlet. do i need to add ne...
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 execute it using tomcat5.5 server. kindly help me how 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 to wait for longer periods and the way to do it...
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 it as a session attribute. What I am trying is...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.