Avatar of mesX
mesX
Flag 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
JSPWeb DevelopmentJava EE

Avatar of undefined
Last Comment
mesX

8/22/2022 - Mon
rrz

Please read
previous discussion  
We can help you with anyway you want to go with this.
JSTL is the easy way to go.  
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
rrz

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
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
Your help has saved me hundreds of hours of internet surfing.
fblack61
SOLUTION
rrz

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
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