Hello
I would like to write to a database a message that might be in greek. How i can do this?
the form that i have is:
<form accept-charset='UTF-8' action="addcommentcheck.jsp" method="post" id="addcommentid">
....
</form>
and the database is utf8_unicode_ci for the name that could be in greek. How i can see the greek message at addcommentcheck.jsp?
Thank you very much

Dani AI

Generated

UTF-8 must be handled end-to-end: browser -> request -> server/JSP -> JDBC -> database -> response. already set the form to send UTF-8 (good), and pointed to related threads. The single most common failure is that the servlet/JSP reads parameters with the wrong encoding (or the JDBC connection writes bytes using the wrong encoding) so the bytes stored in MySQL are already corrupted.

Practical checklist:

  • Ensure the HTML page declares UTF-8 (meta and correct Content-Type header).
  • In JSP/servlet, set the page encoding and call request.setCharacterEncoding("UTF-8") before any getParameter() calls. Prefer a servlet Filter so every request is handled early.
  • Configure the JDBC connection to use Unicode (useUnicode=true and characterEncoding=UTF-8 or equivalent for your driver).
  • Make sure database, table and column character sets support full Unicode; prefer utf8mb4 and a utf8mb4_... collation. Convert existing tables if needed.
  • Ensure the response is sent with charset=UTF-8 (JSP contentType or response.setCharacterEncoding).

Example snippets:

<%@ page pageEncoding="UTF-8" contentType="text/html; charset=UTF-8" %>
request.setCharacterEncoding("UTF-8");
jdbc:mysql://host:3306/db?useUnicode=true&characterEncoding=UTF-8
ALTER TABLE your_table CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

Quick diagnostics: if the DB shows wrong bytes, the problem happened before insert (request decoding or JDBC). If the DB has correct UTF-8 bytes but the browser shows garbled text, the response headers or HTML meta are wrong. Use SHOW VARIABLES LIKE 'character_set%';, SHOW CREATE TABLE your_table;, and SELECT HEX(col) to inspect stored bytes. Helpful references: MDN meta charset, ServletRequest.setCharacterEncoding, and .

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.