title: Best practice struts/jsp/i18n/resourceBundle
body: <p>I am using Struts 2 and Apache tiles, and I'm new to both. I am trying to "clean" some existing sources that don't feel correct to me (tell me if I'm wrong).</p>
  
  <p>I have the following structure : </p>
  
  <ul>
  <li><p>in a layout.jsp :</p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
      &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8"&gt;
      &lt;title&gt;&lt;tiles:getAsString name="title" /&gt;&lt;/title&gt;
      &lt;tiles:insertAttribute name="header" /&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;div id="content-size-and-border"&gt;
          &lt;s:if test="display!='nomenu'"&gt;
              &lt;tiles:insertAttribute name="menu" /&gt;
          &lt;/s:if&gt;         
          &lt;div id="maincontent"&gt;
              &lt;tiles:insertAttribute name="maincontent" /&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  
  &lt;/body&gt;
  </code></pre>
  
  <p> </p></li>
  </ul>
  
  <p>The main content part displays various jsp/action depending on the item-menu clicked. 
  The menu part uses some java code directly in the jsp to generate a number of sub-folders by iterating on a list. </p>
  
  <pre><code>&lt;li class="highlight sousmenu"&gt;&lt;a href="#"&gt;&lt;s:text
      name="menu.demarrage" /&gt;&lt;/a&gt;
      &lt;ul class="niveau2"&gt;
  
          &lt;%
          Locale language = (Locale) session.getAttribute("WW_TRANS_I18N_LOCALE"); 
          // the attribute (used by i18n struts interceptor) 
          // set in session when the user changes the language
  
          if (language == null)
              language = request.getLocale() ;
          // if the language was not changed, get the default Locale from browser
  
          User user = ((CustomUserDetails) SecurityContextHolder.getContext()
                  .getAuthentication().getPrincipal()).getBpmUser();
              if (user != null) {
                  for (Iterator iterator = user.getProcesses().iterator(); iterator
                          .hasNext();) {
                      String processToStart = (String) iterator.next();
                      String processPath = BpmUiConstantes.BPMUI_PROCESS_CONFIG_ROOT + "/" + processToStart ;
                      String processLib = "process." + processToStart + ".label";                              
          %&gt;
  
          &lt;li&gt;
              &lt;a href="&lt;%=request.getContextPath()%&gt;/restricted/DemarrerProcessAvecTache?processName=&lt;%=processToStart%&gt;"&gt;
                  &lt;fmt:setLocale value="&lt;%=language%&gt;"/&gt;
                  &lt;fmt:bundle basename="&lt;%=processPath%&gt;"&gt;
                      &lt;fmt:message key="&lt;%=processLib%&gt;"/&gt;
                  &lt;/fmt:bundle&gt;
              &lt;/a&gt;
          &lt;/li&gt;
  
          &lt;%
                  }   
              }
          %&gt;
      &lt;/ul&gt;
  &lt;/li&gt;
  </code></pre>
  
  <p>I was wondering if there was a better way to achieve the same result, without the java code in the jsp. Is it important to remove the java code from the jsp from a conception point of view ?</p>
  
  <p>The application uses struts i18n interceptor for the language changes. Is there a way to have the menu use a struts i18n interceptor in some way?</p>