• 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:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

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");
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic