Please help with my JSP internationalization issue

I have a problem with I18N in JSP, in particular with forms.

When I enter some Czech characters (for example, "ěőčřžýÑ ...") on my page of the same form, in the " fieldOne" field , and then show the text from this field on page 2 instead of Czech characters, I see this as "ÄÄ". (Note that the second page receives Czech characters with " request.getProperty("fieldOne")")

Here is the source code:

Page 1:

<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>

<%@ taglib uri="http://jakarta.apache.org/struts/tags-bean" prefix="bean" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-html" prefix="html" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-logic" prefix="logic" %>

<html>
 <head></head>
 <body>
    <form action="druha.jsp" method="post">
       <input type="textarea" name="fieldOne">
       <input type="submit">
    </form>
 </body>
</html>

Page Two:

<%@page contentType="text/html" pageEncoding="UTF-8"%>

<%@ taglib uri="http://jakarta.apache.org/struts/tags-bean" prefix="bean" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-html" prefix="html" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-logic" prefix="logic" %>

<html>
 <head></head>
 <body>
    <h1>The text: </h1> <%=request.getProperty("fieldOne")%>
 </body>
</html>

Thanks for the help...

+3
source share
1 answer

Which container are you using? This information is important for such problems.

Try calling anyway

request.setCharacterEncoding("UTF-8");

. . Tomcat , , JSP.

+4

Source: https://habr.com/ru/post/1706240/


All Articles