• 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

ResourcBundle use in Servlets ?

 
Ranch Hand
Posts: 264
Eclipse IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, I have some code in servlet

Locale locale = Locale.getDefault();

ResourceBundle bundle = PropertyResourceBundle.getBundle("i18n.WelcomeBundle",locale,ClassLoader.getSystemClassLoader());

System.out.println("Welcome output :"+bundle.getString("Welcome"));
}

Where should i put i18n.WelcomeBundle_en_US.properties file so that i do not get MissingResourceException.


Thanks in advance.
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Try putting it in WEB-INF/classes.
 
Ranch Hand
Posts: 2308
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I am just confused over the following.

ResourceBundle bundle = PropertyResourceBundle.getBundle("i18n.WelcomeBundle",locale,ClassLoader.getSystemClassLoader());

Why to put system classloader as the classloader of choice.
Why not to use the other version of the same method without an classloader argument in it.
 
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
put it in the WEB-INF/classes dir.
you can also put it in your package:
com.xxx.bundle.properties

and then get the bundle:
ResourceBundle.getBundle("com/xxx/bundle");
reply
    Bookmark Topic Watch Topic
  • New Topic