permaculture playing cards*
The moose likes Servlets and the fly likes How to load xml/properties file at startup while loading the Application in web-Server ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "How to load xml/properties file at startup while loading the Application in web-Server ?" Watch "How to load xml/properties file at startup while loading the Application in web-Server ?" New topic
Author

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

Prabhat Ranjan
Ranch Hand

Joined: Oct 04, 2006
Posts: 391
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

Evan Caballero
Ranch Hand

Joined: Dec 10, 2009
Posts: 59
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)
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60774
    
  65

Spring is not necessary.

Servlet context listeners are part of the Servlet API.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
sagar powar
Greenhorn

Joined: Jan 13, 2010
Posts: 8
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.


SCJP 1.4 - 93%
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60774
    
  65

Yes, as I've already said.
Bnaresh Yad
Greenhorn

Joined: Jan 27, 2010
Posts: 4
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


 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to load xml/properties file at startup while loading the Application in web-Server ?
 
Similar Threads
properites file
When trying to deploy my JSF 2.0 JSP page I get this:
Spring Remoteness
Servlet Context parameters
Invalid Warning of "com.sun.faces.config.ConfigureListener"