I have the following problem related to the internazionalization\localization of an old Java web application.
So I have this situation: I have 2 very similar web application and I had to take a JSP page from the first one and copy it into the second one.
This JSP page contains something like this:
<thead>
<tr>
<th><input id="myCheck" onclick="changeBoxAll(this)" type="checkbox"></th>
<th></th>
<th><fmt:message key="emittente_fatt"/></th>
<th><fmt:message key="mandataria"/></th>
<th><fmt:message key="id"/></th>
<th><fmt:message key="numero_fatt"/></th>
<th><fmt:message key="data_invio"/></th>
<th><fmt:message key="data_approvazione"/></th>
<th><fmt:message key="data_documento"/></th>
<th><fmt:message key="totale_fattura"/></th>
<th><fmt:message key="stato"/></th>
</tr>
</thead>
As you can see in the previous code it contains the tag.
This tag belong to the JSTL tag library and it is used to maps key to localized message and performs parametric replacement.
So, for example, instead the in the first application is shown Invoice Issuer (if the user is engligh) or emittente_fatt=Emittente fattura (if the user is italian).
In the first application (the orignal one from where I take my JSP putted into the second application) it works fine and these date are stored into 2 properties file that are respectivelly names:
- /src/config/l18n/messages_en.properties
- /src/config/l18n/messages_it.properties
(the first one is for the english version and the second one for the italian version).
So into the second web application I had not the l18n subfolder into the /src/config/ folder so, when I perform the previous JSP page I saw the key of the message properties file (something like: ???emittente_fatt??? instead the value Invoice Issuer)
Ok, so I tryed to copy and paste the l18n folder (and all its content) and put it into the /src/config/ of the second web application.
Now if from Intellij I work into my view I can see the link to the bundled messages_en.properties and messages_it.properties (CTRL + clicking on the key of the tag I can chose if open one of these file.
So these properties file seems to be correctly bundled into the project.
The problem is that if I try to run my project I still see the key and not the associated value, I see something like this:
Why? What am I missing? How can I solve this issue and correctly see the value into my th?
EDIT-1:
This is the web.xml content of the destionation webapp (the one in that the internazionalization can't work):
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app PUBLIC
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<display-name>MY APPLICATION NAME</display-name>
<context-param>
<param-name>javax.servlet.jsp.jstl.fmt.localizationContext</param-name>
<param-value>messages</param-value>
</context-param>
<listener>
<listener-class>it.sistinf.ediweb.quartz.QuartzListener</listener-class>
</listener>
<servlet>
<servlet-name>edimon</servlet-name>
<servlet-class>it.sistinf.ediweb.monitor.servlets.Monitoraggio</servlet-class>
<load-on-startup>0</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>edimon</servlet-name>
<url-pattern>/edimon.do/*</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>salwf</servlet-name>
<servlet-class>it.sistinf.ediweb.monitor.servlets.Salwf</servlet-class>
<load-on-startup>0</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>salwf</servlet-name>
<url-pattern>/salwf.do/*</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>/logon.jsp</welcome-file>
</welcome-file-list>
<taglib>
<taglib-uri>http://java.sun.com/jstl/fmt</taglib-uri>
<taglib-location>/WEB-INF/displaytag-11.tld</taglib-location>
</taglib>
</web-app>
This is my entire JSP page:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
<jsp:useBean id="Bean_Dati" scope="session" type="it.sistinf.ediweb.dbutil.GestoreDati"/>
<%@ taglib uri="/WEB-INF/displaytag-11.tld" prefix="display" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<%@ page import="it.sistinf.ediweb.util.Utility" %>
<%@ page import="java.util.Iterator" %>
<%@ page import="java.util.List" %>
<%@ page import="it.sistinf.ediweb.model.RequestCharge" %>
<link rel="stylesheet" href="css/displaytag.css"/>
<link rel="stylesheet" href="css/font.css"/>
<LInk rel="stylesheet" href="css/webedi_thema.css">
<%--<link type="text/css" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.24/themes/ui-darkness/jquery-ui.css" rel="stylesheet">--%>
<LInk rel="stylesheet" href="css/jquery.ui.theme5.css">
<link rel="stylesheet" href="css/claro.css">
<LInk rel="stylesheet" href="css/dataTables/datatable.css">
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="script.js"></script>
<script type="text/javascript" src="js/jquery-1.9.1.min.js"></script>
<script type="text/javascript" src="js/jquery-ui.js"></script>
<script type="text/javascript" src="js/jquery.dataTables.js"></script>
<%
// Per non far fare il caching...
response.setHeader("pragma", "no-cache");
response.setHeader("Expires", "0");
response.setHeader("Cache-Control", "no-cache");
String lingua = (String) javax.servlet.jsp.jstl.core.Config.get(request.getSession(), javax.servlet.jsp.jstl.core.Config.FMT_LOCALE);
request.setAttribute("Autorizza", Bean_Dati.getListaRisultati("ListaCertificazioniNonLette"));
%>
<script>dojoConfig = {parseOnLoad: true}</script>
<script src='js/dojo/dojo.js'></script>
<script>
require(["dijit/Dialog", "dijit/form/TextBox", "dijit/form/Button"]);
</script>
<script type="text/javascript">
function checkAutorizza() {
if (isCheckboxChecked2('item') == false) {
alert('<fmt:message key="no_doc_aut" />');
return false;
} else {
document.getElementById('aut').value = "true";
document.getElementById('notaRifiuto').value = "";
document.forms.inboxform.action = "edi.do?serv=Q.2";
document.forms.inboxform.submit();
return true;
}
}
function checkRifiuta() {
if (isCheckboxChecked2('item') == false) {
alert('<fmt:message key="no_doc_aut" />');
return false;
} else {
document.getElementById('aut').value = "false";
document.forms.inboxform.action = "edi.do?serv=Q.3";
document.forms.inboxform.submit();
return true;
}
}
</script>
<div class="panel-wrapper">
<div class="panel-content">
<form name="inboxform" action="edi.do?serv=Q.2" method=post onsubmit="javascript:return checkAutorizza()">
<input type="hidden" name="autorizza" value="" id="aut">
<input type="hidden" name="notaRifiuto" value="" id="notaRifiuto">
<table id="autorizza" border="0" class="standard-table-cls" style="width: 100%!important">
<thead>
<tr>
<th><input id="myCheck" onclick="changeBoxAll(this)" type="checkbox"></th>
<th></th>
<th><fmt:message key="emittente_fatt"/></th>
<th><fmt:message key="mandataria"/></th>
<th><fmt:message key="id"/></th>
<th><fmt:message key="numero_fatt"/></th>
<th><fmt:message key="data_invio"/></th>
<th><fmt:message key="data_approvazione"/></th>
<th><fmt:message key="data_documento"/></th>
<th><fmt:message key="totale_fattura"/></th>
<th><fmt:message key="stato"/></th>
</tr>
</thead>
<tbody>
<%
//int count = 0;
//List l = (List) Bean_Dati.getListaRisultati("Autorizza");
//List l = (List) Bean_Dati.getListaRisultati("ListaCertificazioniNonLette");
//List l = (List) Bean_Dati.getListaRisultati("ListaCertificazioniNonLette");
List l = (List) request.getSession().getAttribute("requestChargeList");
//String trClass = "odd";
for (Iterator iterator = l.iterator(); iterator.hasNext(); ) {
//String evenOrOdd = "";
RequestCharge ci = (RequestCharge) iterator.next();
//if (trClass.equals("odd")) trClass = "even";
//else trClass = "odd";
/*
if ((count & 1) == 0) {
evenOrOdd = "even";
} else {
evenOrOdd = "odd";
}
count++;
*/
%>
<tr style="cursor:pointer;" onclick="">
<td>
<%if (ci.isAutorizza() && ci.isMaster()) {%>
<input class="myCheck" name="item" type="checkbox" id="<%=ci.getPk_coda()%>"
value="<%=ci.getPk_coda()%>"
<%}%></td>
<td>
<%if (ci.isAutorizza() && ci.isMaster()) {%>
<img
onclick="changeBoxAll2(document.getElementById('myCheck')); openDialog('edi.do?serv=3.B&pk='+'<%=ci.getPk_coda()%>'+'&canale=WEB&autorizza=si','680px','500px','9')"
width="16px" src="img/icona_vedidocumento.png" align=left border=0 alt="Visualizza">
<%} else {%>
<img
onclick="openDialog2('edi.do?serv=3.B&pk='+'<%=ci.getPk_coda()%>'+'&canale=WEB&autorizza=no','680px','500px','9')"
width="16px" src="img/icona_vedidocumento.png" align=left border=0 alt="Visualizza">
<%}%>
</td>
<td><%=ci.getDesc_unita1()%>
</td>
<td><%=(ci.getFornitore() != null ? ci.getFornitore() : (String) request.getSession().getAttribute("mandataria"))%>
</td>
<td><%=ci.getPk_coda()%>
</td>
<td><%=ci.getNum_doc()%>
</td>
<td><%=(ci.getData_in() != null ? ci.getData_in().substring(8, 10) + "/" + ci.getData_in().substring(5, 7) + "/" + ci.getData_in().substring(0, 4) : "") %>
</td>
<td><%=(ci.getData_app() != null ? ci.getData_app().substring(8, 10) + "/" + ci.getData_app().substring(5, 7) + "/" + ci.getData_app().substring(0, 4) : "")%>
</td>
<td><%=(ci.getData_doc() != null ? ci.getData_doc().substring(8, 10) + "/" + ci.getData_doc().substring(5, 7) + "/" + ci.getData_doc().substring(0, 4) : "")%>
</td>
<td align="right"><%=(ci.getTot_fattura()!=null?Utility.getImportFormatLanguage(ci.getTot_fattura(), lingua):"")%></td>
<td title="<%=(ci.getMotivoRifiuto()!=null?ci.getMotivoRifiuto():"")%>"><%=ci.getStato()%>
</td>
</tr>
<%} %>
</tbody>
</table>
</form>
<% if (Bean_Dati.getNumeroRecord("Autorizza") != 0) {%>
<div class="bottoneDiv">
<input class="bottone" readonly="readonly" type="text" value="<fmt:message key="autorizza" />"
onclick="Javascript: checkAutorizza();"/>
<%--<input class="bottone" readonly="readonly" type="text" value="<fmt:message key="rifiuta" />"--%>
<%--onclick="Javascript: checkRifiuta();"/>--%>
</div>
<% } %>
<div id="dialog" title="">
<iframe scrolling="no" frameborder="0" width="100%" height="630px" src="" id="myFrame">
</iframe>
</div>
<div id="dialogReject" title="">
<%--<iframe scrolling="no" frameborder="0" width="100%" height="200px" src="" id="myFrameReject">--%>
<table style="visibility: hidden;" id="rifiutaTable" border="0" class="standard-table-cls"
style="width: 100%!important">
<thead>
<tr>
<th>Inserire note ri rifiuto</th>
</tr>
</thead>
<tr>
<td>
<textarea style="visibility: hidden;" rows="5" cols="50" id="myRejectNote"></textarea>
</td>
</tr>
<tr>
<td>
<input class="bottone" readonly="readonly" type="text" value="<fmt:message key="rifiuta" />"
onclick="rifiuta()"/>
</td>
</tr>
</table>
<%--</iframe>--%>
</div>
</div>
</div>