* ■目次 #contents(fromhere=true) * ■Servlet & JSP ** ServletからJSPにパラメータを渡す >request.setAttribute("string", "文字列を渡す"); ** Servletから受け取ったパラメータを利用する ><%= request.getAttribute("string") %> * ■Servlet * ■JSP ** ページの文字コードを設定する ><%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %> ><%@ page language="java" contentType="text/html; charset=Shift_JIS" pageEncoding="Shift_JIS" %> ><%@ page language="java" contentType="text/html; charset=EUC_JP" pageEncoding="EUC_JP" %> - ページディレクティブはJSPファイルの先頭に記述します。 - JSPファイルの文字コードも同じ文字コードにしておいたほうが無難です。 ** htmlに変数やオブジェクトを出力する ><%= hogehoge %> ** クラスやパッケージをインポートする - java.utilパッケージをインポート ><%@ page import="java.util.*" %> - 自作Beanをインポート ><%@ page import="my.package.MyBean" %> ** コンテキストパスを出力する ><%=request.getContextPath()%> ><form action='<%=request.getContextPath()%>/hogeservlet' method="post"> * ■html ** ページの文字コードをブラウザに伝える ><meta http-equiv="Content-Type" content="text/html; charset="UTF-8"> ><meta http-equiv="Content-Type" content="text/html; charset=Shift_JIS"> ><meta http-equiv="Content-Type" content="text/html; charset="EUC_JP">