title: JSP i18n works on each page separately after setting default language in filter
body: <h1>Intro</h1>
  
  <p><p>I am trying to internationalize (i18n) my Java Web Application which is based on basic <strong>JSPs</strong>/<strong>Servlets</strong>.</p>
  
  <p><p>I am using <strong>JSTL</strong> <code>fmt taglib</code> in combination with <code>Resource Bundle</code> to achieve <strong>i18n</strong> of my application. I am also following <a href="https://stackoverflow.com/a/4278571/5317530">this</a> answer/guide.</p>
  
  <hr>
  
  <h1>Problem &amp; Question</h1>
  
  <p><p>When I choose desired language on some page <strong>e.g.</strong> <code>index.jsp</code>, then this page is translated on selected language, but when I am going by some link <strong>e.g.</strong> <code>signup.jsp</code> then the language is changed to the default, thus i18n works on each page individually.</p>
  
  <p><p>The <strong>Question</strong> is how do i share the language value across all pages?</p>
  
  <hr>
  
  <h1>Code</h1>
  
  <p>First of all I have a Filter which specifies the default/initial language of page.</p>
  
  <p><strong><em>DefaultLocaleFilter.java</em></strong></p>
  
  <pre><code>@WebFilter(filterName = "DefaultLocaleFilter", urlPatterns = {"/app/*"})
  public class DefaultLocaleFilter implements Filter {
  
      @Override
      public void init(FilterConfig filterConfig) throws ServletException {}
  
      @Override
      public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
  
          HttpServletResponse resp = (HttpServletResponse) response;
          HttpServletRequest req = (HttpServletRequest) request;
  
          req.getSession().setAttribute("language", "ru");
          chain.doFilter(request, response);
      }
  
      @Override
      public void destroy() {}
  }
  </code></pre>
  
  <p><br>
  <hr>
  <strong>i18n.lang</strong> is the path to my Resource Bundle (I am using Maven's archetype-webapp)</p>
  
  <p><strong><em>index.jsp</em></strong></p>
  
  <pre><code>&lt;%@ page contentType="text/html;charset=UTF-8" language="java" %&gt;
  &lt;%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %&gt;
  &lt;%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %&gt;
  
  &lt;c:set var="language" value="${not empty param.language ? param.language : not empty language ? language : pageContext.request.locale}" scope="session" /&gt;
  &lt;fmt:setLocale value="${language}"/&gt;
  &lt;fmt:setBundle basename="i18n.lang"/&gt;
  
  &lt;!DOCTYPE html&gt;
  &lt;html lang="${language}"&gt;
  &lt;head&gt;
      &lt;title&gt;&lt;fmt:message key="index.title"/&gt;&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
  
      &lt;h3 class="hero"&gt;&lt;fmt:message key="index.text.welcome"/&gt;&lt;/h3&gt;
  
      &lt;p&gt;&lt;fmt:message key="index.text.overview"/&gt;&lt;/p&gt;&lt;br&gt;
  
      &lt;a class="button" href="signup"&gt;&lt;fmt:message key="index.button.signup"/&gt;&lt;/a&gt; &amp;nbsp;
      &lt;a class="button" href="login"&gt;&lt;fmt:message key="index.button.login"/&gt;&lt;/a&gt;
  
      &lt;span class="lang"&gt;
          &lt;form&gt;
              &lt;select name="language" onchange="submit()"&gt;
                  &lt;option value="en" ${language == 'en' ? 'selected' : ''}&gt;EN&lt;/option&gt;
                  &lt;option value="ru" ${language == 'ru' ? 'selected' : ''}&gt;RU&lt;/option&gt;
              &lt;/select&gt;
          &lt;/form&gt;
      &lt;/span&gt;            
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p><br>
  <hr>
  <strong><em>signup.jsp</em></strong></p>
  
  <pre><code>&lt;%@ page contentType="text/html;charset=UTF-8" language="java" %&gt;
  &lt;%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %&gt;
  &lt;%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %&gt;
  
  &lt;c:set var="language" value="${not empty param.language ? param.language : not empty language ? language : pageContext.request.locale}" scope="session" /&gt;
  &lt;fmt:setLocale value="${language}"/&gt;
  &lt;fmt:setBundle basename="i18n.lang"/&gt;
  
  &lt;!DOCTYPE html&gt;
  &lt;html lang="${language}"&gt;
  &lt;head&gt;
      &lt;title&gt;&lt;fmt:message key="signup.title"/&gt;&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
  
      &lt;h3 class="hero"&gt;&lt;fmt:message key="signup.text.welcome"/&gt;&lt;/h3&gt;
  
      &lt;%-- Here is the form to Sign Up --%&gt;
  
  
      &lt;span class="lang"&gt;
          &lt;form&gt;
              &lt;select name="language" onchange="submit()"&gt;
                  &lt;option value="en" ${language == 'en' ? 'selected' : ''}&gt;EN&lt;/option&gt;
                  &lt;option value="ru" ${language == 'ru' ? 'selected' : ''}&gt;RU&lt;/option&gt;
              &lt;/select&gt;
          &lt;/form&gt;
      &lt;/span&gt;            
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>