aspose file tools*
The moose likes Servlets and the fly likes Web applications with various configurations files Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Web applications with various configurations files" Watch "Web applications with various configurations files" New topic
Author

Web applications with various configurations files

Alex Florentino
Ranch Hand

Joined: Dec 12, 2006
Posts: 48
Hi all,

I have an site that will respond for various domains.

sample:

<Host name="site1.site.com" debug="1" appBase="c:\foldersrc" unpackWARs="true" autoDeploy="true">
<Logger className="org.apache.catalina.logger.FileLogger" directory="logs" prefix="site1." suffix=".txt" timestamp="true"/>
<Context path="" docBase="." debug="0" reloadable="true" crossContext="true"></Context>
</Host>

<Host name="site2.site.com" debug="1" appBase="c:\foldersrc" unpackWARs="true" autoDeploy="true">
<Logger className="org.apache.catalina.logger.FileLogger" directory="logs" prefix="site2." suffix=".txt" timestamp="true"/>
<Context path="" docBase="." debug="0" reloadable="true" crossContext="true"></Context>
</Host>

then the folder of source of my web application will be same for all domains.

but I need that a each domain has your own configuration file(properties file).

someone have some good idea how I can make it ?

thanks.
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

You can place context init param entries in the <Context ../> tag for each instance. This would allow you to set a different path for each app's config files.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Alex Florentino
Ranch Hand

Joined: Dec 12, 2006
Posts: 48
ok,
but I still need load this file, where I could load this file ? when the context is started ? it is good a idea ?

I create the Context Listener:

are in WEB-INF/classes/


and my server.xml in context element I put this entry:



but when I start tomcat I get this error:



whats I made wrong ? any suggestion ?

thanks.

[ October 05, 2007: Message edited by: Alex Florentino ]
[ October 05, 2007: Message edited by: Alex Florentino ]
Alex Florentino
Ranch Hand

Joined: Dec 12, 2006
Posts: 48
I changed instead of create context listener I create a servlet and put it:



in my source code.

and init method I load application configuration.
[ October 05, 2007: Message edited by: Alex Florentino ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Web applications with various configurations files