1

I have to build a multi-language web site in JSP/Servlet.

I'm considering JSTL for the i18n, and I've some general questions:

1) is it possible to handle with jstl both the language selection by hand (e.g. through a pull-down menu or a link) and the automatic language recognition?

2) what is the better approach if the most part of strings are dynamic (retrieved from a database)?

Sefran2
  • 3,578
  • 13
  • 71
  • 106

1 Answers1

1

is it possible to handle with jstl both the language selection by hand (e.g. through a pull-down menu or a link) and the automatic language recognition?

Yes. See also How to internationalize a Java web application?.


what is the better approach if the most part of strings are dynamic (retrieved from a database)?

You'd need to create a custom ResourceBundle.Control which you inject in the request scope by a Filter. This filter should basically take over the job of <fmt:setLocale> and <fmt:setBundle>.

request.setAttribute("bundleName", yourCustomResourceBundle);

See also internationalization in JSF with ResourceBundle entries which are loaded from database (although JSF targeted, the idea is the same for plain JSP; as said, you'd only need a Filter instead to set it).

Community
  • 1
  • 1
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • Thank you for the complete answer. I've an error on your example in "How to internationalize a java web application", precisely in the option tag: Multiple annotations found at this line: - Invalid location of text (''}) in tag ( – Sefran2 Feb 24 '12 at 09:11