Note in Listing 3-12 that the base name of the resource bundle has been changed.
Hence, in this case the resource bundles that hold the mapping information will be
named insurance-views.properties , insurance-views_fr_CA.properties , and so on. A lot of
things happen under the hood because of this configuration. I will summarize them here
so you can better understand:
1. A request of policydetails.do is intercepted by the dispatcher servlet.
2. The request is handled by the PolicyDetailsController page controller. It sets the
logical view name that should be used to present the data returned by the busi-
3. The dispatcher servlet invokes the view resolver with the logical view name
returned by the controller and the locale information available with the request.
4. The ResourceBundleViewResolver first detects the appropriate resource bundle
based on the locale.
5. The logical view name is used to detect the appropriate view class configured in
the resource bundle. In this is the value of the property policydetails.class .
6. Finally, an instance of JstlView is created, and the value of the configuration
parameter policydetails.url is injected into this object and returned to the dis-
The design presented here may be used for an application supporting two locales,
but it can have serious side effects. Using a properties file for view management is a cum-
bersome approach. It can be a nightmare to maintain this application, because we will
add n JSPs per locale. In other words, if we support m locales, we will have m * n JSP files.
Add to this the view configuration file that is required for each locale. So, effectively we
will have m *(1+ n ) JSP and configuration files to maintain. A better approach is to have a
single JSP for all locales. It is backed by m resource bundles for the various locales that
the application intends to support. The resource bundles can then be used in the JSP
using the View Helper pattern described later. So, in effect we have ( n + 2 m ) files to main-
tain, which makes things significantly easier.
The XmlViewResolver does not support localized view resolution and should replace
ResourceBundleViewResolver if we intend to implement the solution of one JSP for all
locales. So, with XmlViewResolver , there is just a single PolicyDetails.jsp catering to all the
users with the localized labels stored in resource bundles. Most developers find it more
convenient to configure the view mapping in an XML file.