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)?
Yes. See also How to internationalize a Java web application?.
You’d need to create a custom
ResourceBundle.Controlwhich you inject in the request scope by aFilter. This filter should basically take over the job of<fmt:setLocale>and<fmt:setBundle>.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
Filterinstead to set it).