0

Can't find a solution for my internationalization problem within jsp pages. I've read this, okay - how to internationilize a web-app

Buut. Everything works fine, but for forms validation I use html5, and all error messages are shown in the default locale, ru_RU in my case. Haven't managed to solve it by myself, will be grateful for help.

My code on test page:

<%@ page pageEncoding="UTF-8" contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>

<c:set var="language" value="${(empty locale)? applicationScope.base_locale : locale}" scope="session"/>
<fmt:setLocale value="${language}"/>
<fmt:setBundle basename="i18Messages"/>

<form>
  <input type="text" required name="name">
  <input type="submit" value="<fmt:message key="SUBMIT_LABEL"/>">
</form>

P.S. Variable 'locale' belongs to the session and changes correctly. Even if hardcode 'en_US' locale in the 'language', error messages are still in russian.

if to insert here this two rows:

pageContext.request.locale - ${pageContext.request.locale}<br/>
pageContext.response.locale - ${pageContext.response.locale}<br/>

..I can see, that the request locale is always ru_RU, while the response one is changing.

Community
  • 1
  • 1
Julia S
  • 3
  • 3

0 Answers0