Search code examples
jsputf-8character-encodingweblogicstruts-1

Encoding issue in html:form with Struts 1.2


I have an application with Struts 1.2 and in a .jsp I've created a form using html tag, this is part of my code:

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://struts.apache.org/tags-html-el" prefix="html" %>
...
<html:form action="/myAction" method="post">
...
  <display:table name="ListOfEntries" sort="external" requestURI="/myEntryAction.do" uid="row">
  ...
    <display:column titleKey="label.label" sortable="true" sortProperty="label">
      <span id="staticlabel<c:out value="${row.id}" />">
        <bean:write name="row" property="label" />
      </span>
      <html:text name="MyEntryForm" property="editedEntry.label" value="${row.label}" disabled="true" style="display:none" size="35"/>
    </display:column>

So, when a edit an entry with a special character Ç, in my MyEntryForm I get it as Ã.

Thanks in advance.

UPDATE: I forgot to mention that I'm using Weblogic.


Solution

  • I found what was the problem.

    In the question I forgot to mention that I'm using Weblogic as server. Debugging with Firefox or Chrome I checked that the request from my browser was correct, with the correct character, so it had to be the server.

    In my project, I have a weblogic.xml, with this content:

    <?xml version="1.0" encoding="UTF-8"?>
    
    <weblogic-web-app
        xmlns="http://www.bea.com/ns/weblogic/90"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://www.bea.com/ns/weblogic/90
        http://www.bea.com/ns/weblogic/90/weblogic-web-app.xsd">
    
    <description>My Struts Application</description>
    
    <context-root>RootOfMyApplication</context-root>
    
    <container-descriptor>
        <prefer-web-inf-classes>true</prefer-web-inf-classes>
        <show-archived-real-path-enabled>true</show-archived-real-path-enabled>
    </container-descriptor>
    
    </weblogic-web-app>
    

    And I adding this the problem was solved:

    <charset-params>
        <input-charset>
            <resource-path>/*</resource-path>
            <java-charset-name>UTF-8</java-charset-name>
        </input-charset>
    </charset-params>