File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Tomcat and the fly likes how to set different dir to resource bundle file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "how to set different dir to resource bundle file" Watch "how to set different dir to resource bundle file" New topic
Author

how to set different dir to resource bundle file

Meir Yan
Ranch Hand

Joined: Apr 27, 2006
Posts: 597
is there any way to configure tomcat see ResourceBundle files other then in the WEB-INF\classes directory?
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Resource bundles are found in the JVM classloaders classpath.
You could bundle them into jars and put them under WEB-INF/lib.

Where do you want to put them?


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

Joined: Apr 27, 2006
Posts: 597
i will like to but them in directory in my webapp
something like : webapps\myApp\include
so I need to add this dir to my classpath?
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Tomcat ignores your classpath.
It finds resources by looking in a series of directories.

This is why we need to put them in the classes directory or in a jar file under the lib directory.
Gabriele Muscas
Greenhorn

Joined: Jul 06, 2011
Posts: 3
Hi,
i've create a custom class loader.



From my code, i get the classloader and call the addCustomRepositoryOrLocation method but ResourceBundle not works...



Search in progress...

Bye

Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16019
    
  20

A) It's not WEB-INF\classes, it's WEB-INF/classes. A true WAR is a ZIP file, not a directory and you use DOS pathname separators at your peril, since Java would much rather interpret them as escape character.

B) You DO realize that if you don't put resources under WEB-INF, anyone who wants to can potentially retrieve them by URL (and in fact, WILL be able to, by default). Which is a potential security exploit.

C) What benefit is kludging up a custom classpath going to gain you here anyway?


Customer surveys are for companies who didn't pay proper attention to begin with.
Gabriele Muscas
Greenhorn

Joined: Jul 06, 2011
Posts: 3
Hi Tim,
i would like to create differents directories in which put the properties files.



Now, I'm trying ResourceBundleThemeSource with the Spring framework, but the problem is with the JVM.

I continue to seek a solution.

Thanks,
Gabriele
Gabriele Muscas
Greenhorn

Joined: Jul 06, 2011
Posts: 3
Hi,
this works for me:



In the class loader i've this code:


So, my problem is a spring problem.

Bye,
Gabriele
 
Consider Paul's rocket mass heater.
 
subject: how to set different dir to resource bundle file