Link to home
Create AccountLog in
Avatar of mesX
mesXFlag for Austria

asked on

Reading an XML file in WEB-INF with Bean

Hi there experts,

i have a short question:
I'm currently writing my own Web Application with Java and this Webapplication has its own configuration xml files. These files are under the WEB-INF folder, so only the Servlet or JSP can access it.
Now i want to write a Java Bean that reads this config-files and provides some getter functions...
The reason, why i want to write a bean is, because this config files should be accessed by many servlets and some JSPs.

How can i access the config files with a java bean?
and what would be the best way to parse the XMLs?


thx for your help and best regards!
manuel
Avatar of rrz
rrz
Flag of United States of America image

Please read
previous discussion  
We can help you with anyway you want to go with this.
JSTL is the easy way to go.  
Avatar of mesX

ASKER

Hi and thx for your comment!
As i understand JSTL is only for JSP pages, isn't it?
... and i can't use it within a Java Bean?

Or is my understanding of a Java Bean wrong?
What i want to do is, that my Servlets and JSPs create an Object from my "ApplicationConfig" class which parses the XML and has some getter functions like "String[] getAllEmployeeNames()". So if i change the XML file one day, i just have to re-write my ApplicationConfig class.

Please correct me if my idea is not a good one, because i'm very new to all this :)

regards
Manuel
ASKER CERTIFIED SOLUTION
Avatar of rrz
rrz
Flag of United States of America image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Avatar of mesX

ASKER

You're absolutely awesome!!!! THANK YOU VERY MUCH!

I just have a very small question:
What if i put the employee.xml directly under the WEB-INF folder? Or in my case /WEB-INF/configs/employee.xml? How can i access files inside the WEB-INF folder but outside the classes folder?


best regards
Manuel
SOLUTION
Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Avatar of mesX

ASKER

Thank you so much for all your help! You're a truly expert ;)

I hope you can help me in my future questions too (and i will surely have many  ;) )

best regards
Manuel