Hello,
I developed a JSF2.2 web app in NetBeans 7.4. It worked great on Apache Tomcat 7.0.50. But now I switched to GlassFish 4 and I have a problem with some Serbian characters (Ć, Č, Š, Đ, Ž...)
MySQL database has utf8_general_ci collation, as well as all the tables and every varchar column.
Connection URL:
jdbc:mysql://localhost:3306/sportal?useUnicode=true&characterEncoding=UTF-8&characterSetResults=UTF-8
web.xml has the following part:
<context-param>
<param-name>PARAMETER_ENCODING</param-name>
<param-value>UTF-8</param-value>
</context-param>
supporters.xhtml file where I display the table content:
<h:dataTable id="listSupportersTable" value="#{supportersBean.list}"...>
...
<h:outputText value="#{row.name}"/>
...
</h:dataTable>
In SupportersBean.java I generate a list and for debugging purposes I print the result:
...
while (resultSet.next()) {
supporter.setName(resultSet.getString("name"));
System.out.println(resultSet.getString("name") + ", " + supporter.getName());
list.add(supporter)
}
...
For testing purposes, I made one entry in the table, name=Ć (and it displays correctly in MySQL). On the supporters.xhtml page, the name is also Ć, but the println gives: Ć, Ć
For editing the entry, I created a commandLink on the supporters.xhtml page, with action:
action="#{supportersBean.editSelected(event)}"
...and I gave it a parameter:
<f:param name="supportersName" value="#{row.name}"/>
Here's the editSelected procedure:
public String editSelected(AjaxBehaviorEvent event) {
newName=FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get("supportersName");
System.out.println("newName="+newName); // for debugging
isEditing = true;
return "editSupporters.xhtml?faces-redirect=true";
}
The println gives me: newName=Ć
The editSupporters.xhtml part:
<h:inputText value="#{supportersBean.newName}"/>
In this field I see the character Ä. I don't change anything here, I only click the Save button, which does the following:
supporter.setName(newName);
System.out.println("Updated: "+newName);
dao.update(supporter);
The println gives: Updated: Ć
After this, the outputField on my supporters.xhtml page has the value ÃÂ. If I click Edit again, the inputText field will have the value: ÃÂÃÂ, and when I click Save, the outputField will be ÃÂÃÂÃÂÃÂ...
Finally, after those two edit/saves, I check my table via phpMyAdmin. The value in the column is: ÃÂ
Does anyone has any idea what the problem could be???