In this tutorial, we are going to understand the different scenarios where we might get encoding issues while building the Java application as a war or jar file and deploy it to the server.
The main encoding issue here is, for some languages like Hebrew, Chinese, Arabic, etc there might get the chance of appearing as question marks instead of actual specific text. This issue might be due to different cases.
1. Sometimes the serverside rendering language like jsp, gsp pages might cause the issue we can use the following tag in those pages.
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
jdbc:mysql://hostname/database_naeme?useUnicode=yes&&characterEncoding=UTF-8
CREATE DATABASE database_name DEFAULT CHARACTER SET "utf8" COLLATE "utf8_general_ci";
Make sure to change the actual database instead of [database_name].4. If we are using hibernate then better to configure the settings as
5. If we are using build tools like Jenkins for deployment we need to configure the encoding
In Jenkins: we can create a global variable and set encoding config as below:
hibernate.connection.charSet=UTF-8
hibernate.connection.characterEncoding=UTF-8
hibbernate.connection.useUnicode=true