0
jspファイルの文字化け
Tomcat5.0.28 Apache 2.2 使用 win XP
htmlファイルに入力フォームをつくり、そこに入力された内容をgetで取得し、jspページにて表示するというプログラムなのですが、フォームで日本語を送信すると、文字化けしてしまいます(日本語部分が?で表示される)。
尚、フォームを使わない通常のjspページは、きちんと文字が表示されるので
getで取得したことが問題と思い、下記ページを参考に、server.xmlを書き換えたのですが、まだ直りません。
http://d.hatena.ne.jp/voltz0/20060816/1156109889
ほかに直すべき場所があるのでしょうか?教えてください。
以下、ソースの表示
*HTMLページ*
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<link rel="stylesheet" href="style.css" type="text/css" / >
<title>入力頁</title>
</head>
<body>
<p>
<form action = "input.jsp">
おなまえ : <input type = "text" name = "name" size = 32><br>
生年月日 : <input type = "text" name = "birthday" size = 20><br>
<br>
<input type = "submit" value = "OK">
</form>
</p>
</body>
</html>
*jspページ*
<%@ page contentType = "text/html; charset = Shift_JIS" pageEncoding="Shift_JIS"%>
<%
// ユーザーからの入力を出力する
// パラメータの取得
request.setCharacterEncoding("Shift_JIS");
String name = request.getParameter("name");
String birthday = request.getParameter("birthday");
// 文字コードの変換を行う
name = new String(name.getBytes("8859_1"), "Shift_JIS");
birthday = new String(birthday.getBytes("8859_1"), "Shift_JIS");
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<link rel="stylesheet" href="style.css" type="text/css" / >
<title>ユーザーからの入力を出力する</title>
</head>
<body>
<p>あなたが入力した内容</p>
<p><ul>
<li>おなまえ: <%= name %>
<li>生年月日: <%= birthday %>
</ul>
</p>
</body>
</html>