Author: jfrederic.clere(a)jboss.com
Date: 2007-12-03 10:25:04 -0500 (Mon, 03 Dec 2007)
New Revision: 362
Modified:
sandbox/webapps/src/TestFilter.java
sandbox/webapps/src/TestServlet.java
Log:
UTF8 tests (for firefox example that do UTF-8 but don't tell it).
Modified: sandbox/webapps/src/TestFilter.java
===================================================================
--- sandbox/webapps/src/TestFilter.java 2007-12-03 14:48:54 UTC (rev 361)
+++ sandbox/webapps/src/TestFilter.java 2007-12-03 15:25:04 UTC (rev 362)
@@ -66,6 +66,14 @@
HttpServletRequest req = (HttpServletRequest)request;
HttpServletResponse res = (HttpServletResponse)response;
+ // Don't call it for the TestServlet servlet
+ String path = req.getServletPath();
+ System.out.println("TestFilter.doFilter: " + path);
+ if (path.compareTo("/TestServlet") == 0) {
+ chain.doFilter(request, response);
+ return;
+ }
+
// get action
String action = req.getParameter("do");
if (action == null) {
Modified: sandbox/webapps/src/TestServlet.java
===================================================================
--- sandbox/webapps/src/TestServlet.java 2007-12-03 14:48:54 UTC (rev 361)
+++ sandbox/webapps/src/TestServlet.java 2007-12-03 15:25:04 UTC (rev 362)
@@ -69,6 +69,7 @@
}
response.setContentType("text/html");
+ response.setCharacterEncoding("UTF8");
PrintWriter out = response.getWriter();
out.println("<html>");
@@ -199,9 +200,20 @@
out.println("</form>");
out.print("<p><a href=\"");
- out.print(response.encodeURL("TestServlet?dataname=foo&datavalue=bar"));
+ String url = "TestServlet?dataname=" + dataName +
"&datavalue=" + dataValue;
+ out.print(response.encodeURL(url));
out.println("\" >URL encoded </a>");
+ out.print("<p><a href=\"");
+ url = "TestServlet?dataname=" + dataName +
"&datavalue=èéâçûàAAA";
+ out.print(response.encodeURL(url));
+ out.println("\" >URL encoded with datavalue=èéâçûàAAA</a>");
+
+ out.print("<p><a href=\"");
+ url = "TestServlet?dataname=" + dataName +
"&datavalue=عربي";
+ out.print(response.encodeURL(url));
+ out.println("\" >URL encoded with datavalue=عربي</a>");
+
out.println("</body>");
out.println("</html>");
@@ -217,6 +229,7 @@
HttpServletResponse response)
throws IOException, ServletException
{
+ request.setCharacterEncoding("UTF-8");
doGet(request, response);
}
Show replies by date