サーブレットとセッション③

public class CreateHtml {

	public String getHtmlAll(String title, String body) {
		String header = "<html><head>"
				+ "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">"
				+ "<title>" + title + "</title>" + "</head><body>"
				+ "Nagatter To Twitter<br /><br />";
		String footer = "</body></html>";

		return header + body + footer;
	}

	public void printHtml(HttpServletResponse res, String body)
			throws IOException, TwitterException {
		// 文字コード設定
		res.setContentType("text/html; charset=utf-8"); // getWriter()を呼び出す前に設定
		res.setCharacterEncoding("utf-8");

		PrintWriter writer = res.getWriter();
		writer.print(getHtmlAll("", body));
	}

}