/******************************************** ブラウザの入力データを受け取ってエコーバック ********************************************/ import java.io.IOException; import java.io.PrintWriter; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.ServletException; @SuppressWarnings("serial") public class PostServlet extends HttpServlet{ /***********doPost************/ public void doPost(HttpServletRequest req, HttpServletResponse res) throws IOException, ServletException{ res.setContentType("text/html;charset = shift_jis"); //シフトJIS //パラメータの取り込み //テキストボックス String p = req.getParameter("param1"); //パラメータを取得 String text = new String(p.getBytes("iso8859-1"),"JISAutoDetect"); //byte列をエンコードして新しい文字列を作る //パスワード p = req.getParameter("param2"); //パラメータを取得 String pass = new String(p.getBytes("iso8859-1"),"JISAutoDetect"); //byte列をエンコードして新しい文字列を作る //ラジオボタン p = req.getParameter("param3"); //パラメータを取得 String lang = new String(p.getBytes("iso8859-1"),"JISAutoDetect"); //byte列をエンコードして新しい文字列を作る //チェックボックス String[] kamoku = req.getParameterValues("param4"); //選択されている全ての項目の値を取得 for(int i = 0;i < kamoku.length;i++){ kamoku[i] = new String(kamoku[i].getBytes("iso8859-1"),"JISAutoDetect"); } //HTMLの生成と送信 PrintWriter out = res.getWriter(); //道を作る out.println("
"); //HTMLの生成 out.println("