Charsets:Non-UTF8 Forms
From OpenEMM Wiki
If you want to embed the newsletter subscription form into an existing webpage, the webpage may not use UTF-8. Any form within such non-UTF8 pages, will be sent using the charset-setting of the page. But OpenEMM expects the data to arrive in UTF-8.
Often, the pages that contain the form, cannot be changed to use UTF-8. Some browsers support the "accept-charset"-attribute of the form-tag. That attribute tells the browser, in which charset to send the data. But one important browser doesn't support it: Microsoft's Internet Explorer (up to version 7).
Here's an alternative:
- locate the folder webapps/openemm/htdocs/
- create the file test/doform.jsp with the following contents:
<%
//set charset
request.setCharacterEncoding("ISO-8859-15");
//force decoding by calling getParameterMap()
request.getParameterMap();
//forward request
pageContext.forward("/form.do");
%>
Note: Change the ISO-8859-15 to the charset matching your page. Use cp1252 instead of ISO-8859-1
because browsers send cp1252 even if they are told to use ISO-8859-1.
WARNING: Browsers out there have the habit of sending HTML unicode entities for characters not expressable in the chosen charset. These should be decoded before we forward the request to the form.do-servlet. This will be available in a more advanced version of the suggested JSP-page coming soon ...
The page will use a specific side-effect of the Servlet/JSP-Container:
- Once the querystring or POST-data has been decoded with a certain charset, the charset cannot be changed anymore.
So this page will decode the querystring and POST-data with a certain charset, and will then forwards the request to
the OpenEMM-servlet that resides behind the path "/form.do".
You can now use that JSP-page as the form-action for all your non-UTF8 pages. Here's an example:
before: <form action="/url/to/openemm/form.do" method="post"> after: <form action="/url/to/openemm/test/formdo.jsp" method="post">