0

I have a jsp like this :

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>POST</title>
</head>
<body>
    <form action="FormServlet" method="post">
        name: <input type="text" name="name"/>
        <input type="submit" name="submit"/>
    </form>
</body>
</html>

when i POST, i debugged it by Fiddler, but I find there is not charset defind in contentType, why? I have define contentType in jsp file top, when I post my form, It didn't use the charset?

this is the result in fiddler when I post:

enter image description here

I debug in Tomcat class, I find because the contentType didn't have charset, so tomcat use its default charset, I want to know whether the result is correct, the contentType didn't contain charset, or I have some wrong in somewhere?

Rocky Hu
  • 1,326
  • 4
  • 17
  • 32

1 Answers1

3

The charset you provided in

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

is the content type (not necessarily as a header, but as a hint to the client) of the current response, ie. the rendered JSP. It has no relation to any future requests.

You can set the charset for form submission by following the instructions here.

Community
  • 1
  • 1
Sotirios Delimanolis
  • 274,122
  • 60
  • 696
  • 724