• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to load xml/properties file at startup while loading the Application in web-Server ?

 
Ranch Hand
Posts: 397
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

In Web Application 1st Web.xml file loaded and while loading the context of the web-application.

We use DispatcherServlet to load the ApplicationContext.xml file for Spring configuration file at start-up also we load faces-config.xml for JSF faces context.

How can we load any another xml file or properties file at start-up and how to configure it in web.xml file.


Regards,
prabhat

 
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
you can add a listener declaration in your web.xml file, that will "call" an implementation of ApplicationContextListener or something like this (it is part of the spring API)
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Spring is not necessary.

Servlet context listeners are part of the Servlet API.
 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This might help you.

You can write custom class which implements "ServletContextListener" interface and implement method "contextInitialized()".
In this method, you will get "ServletContextEvent" object from which you can get "ServletContext" object.

Latter, this "ServletContext" object can be used to create path to external configuration files on server.
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, as I've already said.
 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Prabhat Ranjan wrote:Hi,

In Web Application 1st Web.xml file loaded and while loading the context of the web-application.

We use DispatcherServlet to load the ApplicationContext.xml file for Spring configuration file at start-up also we load faces-config.xml for JSF faces context.

How can we load any another xml file or properties file at start-up and how to configure it in web.xml file.


Regards,
prabhat


 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic