• 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

How to load a properties file from JSP

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I am using JPF controllers. Already, i am loading a properties file in the controller(using annotations @Jpf.Controller(messageBundles = { @Jpf.MessageBundle(bundlePath = "validation.validator.Messages") },). I have a problem. Depending on one of the request variables, i need to load different properties files. All these property files have same keys, but with different messages. I need to take the user to different sites(though internally, the backend logic remains same...Look and feel of the front end along with messages to be shown change to make the users feel they are being directed to a different site).

I am thinking of loading the properties file from the JSP when the user logs in first time from login page so that these properties are available until the session expires & not read the properties file in Controller. What is the best way to do it?
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have no idea what JPF is, but whatever it is, loading things in a JSP is not the right answer. JSPs are for generating views, not processing and not business.
 
Gopinadh Upadhyayula
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Jpf.Controller is an annotation used by netui pageflow. This can be treated like our regular servlets.
 
Gopinadh Upadhyayula
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I found an alternative to fix this issue. It is kind of a hack to Internationalization feature.

In the JSP, use a Locale object (using language constructor  Locale locale = new Locale(“TEST”)) to be put in session.

<%
Locale locale = new Locale(“TEST”);
request.getSession().setAttribute(“locale”, locale);
%>

Have the page flow controller use the below annotation to mention about properties file.

@Jpf.Controller(messageBundles = { @Jpf.MessageBundle(bundlePath = "com.validator.Messages") })

When reading the errors using netui tag, mention the session attribute name for the locale (This tag looks for session attribute only using the locale name).
<netui:errors locale="locale"/>

And have the proper message resource properties file name Messages_TEST.properties in the com.validator path under “src” in the web project.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic