Internatilization and Localization in JSP

using Java Standard Tag Library a.k.a. JSTL!

Put this in web.xml
<context-param>
    <param-name>javax.servlet.jsp.jstl.fmt.localizationContext</param-name>
    <param-value>application-messages</param-value>
</context-param>

Now add two files under src\main\java\resources
  • application-messages_tr.properties
  • application-messages_en.properties

Contents for _tr version
title.page=Merhaba D\u00FCnya

Contents for _en version
title.page=Hello World

And finally in the jsp file:
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<h2><fmt:message key="title.page" /></h2>

Now access the page with 2 different browsers where one has accept-language = tr and the other one en.