Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Tomcat Encoding Test Page

DZone's Guide to

Tomcat Encoding Test Page

·
Free Resource
From: Oliver Paulus, http://blog.code-project.org

This is a Tomcat encoding test page. Tested with Tomcat 5.0, 5.5 and 6.0.


<%@ page 
  pageEncoding="utf-8" 
  language="java"
  contentType="text/html; charset=utf-8"
%>
   

  
  



<%
  /* uncomment next line to see that "setCharacterEncoding" call
     will not work anymore if any parameter read before */ 
  //String testParamBefore = request.getParameter("test");  

  request.setCharacterEncoding("utf-8"); 
  String test = request.getParameter("test");
  if (test != null) {
    out.write("the length of the test value after decoding: " + test.length());
  }
  out.write("
"); out.write("the value of the test parameter: " + test); out.write("
"); %>
Topics:

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}