How to display Arabic word in java server page?

二次信任 提交于 2019-12-06 14:47:59
A4L

You need to set the proper character encoding utf8 or utf16

In your JSP you need to insert the page directive for the encoding

<%@ page pageEncoding="utf-8" %>
<!DOCTYPE html>
<html>
<body>
    <h2>ا ب ت ث ج ح خ د ذ ر ز س ش ص ض ط ظ ع غ ف ق ك ل م ن ه و ي</h2>
</body>
</html>

In a Servlet you need to set the content type in the response object

@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) 
        throws ServletException, IOException {
    resp.setContentType("text/plain; charset=utf-8");
    PrintWriter writer = resp.getWriter();
    writer.write("ا ب ت ث ج ح خ د ذ ر ز س ش ص ض ط ظ ع غ ف ق ك ل م ن ه و ي");
}

Note that if you have String literals containing arabic letter then the file also has to be saved in utf8 or utf16

you need to set http response encoding style UTF8

like...

<%@ page pageEncoding="UTF-8" %>

Also see this article for more Reference here

try this code may help you.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!