Servlet(サーブレット)リファレンス(逆引き)

Servlet(サーブレット)リファレンス
 
Web struts.wasureppoi.com
リクエストデータの文字コードを取得する:HttpServletRequest#getCharacterEncoding()
スポンサード リンク

リクエストデータの文字コードを取得するには、HttpServletRequest#getCharacterEncoding()

構文
javax.servlet.http.HttpServletRequest
 public String getCharacterEncoding( )
説明
getCharacterEncodingメソッドは、リクエストデータの文字コード(Windows-31J、SJIS、EUCなど)を取得する。
  
例1) リクエストパラメータの文字コードを取得する。

public class SampleServlet extends HttpServlet {

  public void doGet( HttpServletRequest request, HttpServletResponse response )
      throws ServletException,IOException {

    response.setContentType("text/html;charset=Windows-31J");

    request.setCharacterEncoding("Windows-31J");

    PrintWriter out = response.getWriter();
    out.println("<html><body>");
    out.println("encoding=" + request.getCharacterEncoding());
    out.println("param01=" + request.getParameter("param01"));
    out.println("</body></html>");
   }
}



スポンサード リンク


リクエストパラメータを取得する:HttpServletRequest#getParameter()
配列形式のリクエストパラメータを取得する:HttpServletRequest#getParameterValues()
リクエストパラメータ名を全て取得する:HttpServletRequest#getParameterNames()
リクエストパラメータ名と値のセットを全て取得する:HttpServletRequest#getParameterMap()
リクエストデータの文字コードをセットする:HttpServletRequest#setCharacterEncoding()
リクエストデータの文字コードを取得する:HttpServletRequest#getCharacterEncoding()
リクエストスコープの情報を取得する:HttpServletRequest#getAttribute()
リクエストスコープの情報の属性名を全て取得する:HttpServletRequest#getAttributeNames()
リクエストスコープの情報を設定する:HttpServletRequest#setAttribute()
リクエストスコープの情報を削除する:HttpServletRequest#removeAttribute()
HTTPリクエストのメソッド名を取得する:HttpServletRequest#getMethod()

Servletへ
忘れっぽいエンジニアのJakarta Strutsリファレンス TOPへ