以下では、これらのメソッドを使って、リクエストされたURLからパス情報を取り出す例をいくつか紹介します。リクエストされたURLは、仮に「http://localhost:8080/javatips/ServletPath/sample_param/」とします。 out.println(request.getContextPath()); // /javatips out.println(request.getServletPath()); // /ServletPath out.println(request.getPathInfo()); // /sample_param/ out.println(request.getPathTranslated()); // C:\Program Files\Apache Software Foundation\Tomcat 5.0\webapps\
サーブレットが呼ばれた時のURIを取得する方法を確認します。(ただし、ここでURIやURLと読んでいるものは一般的に言われている厳密なものとは若干異なります)。 リクエストのURIを取得するには「HttpServletRequest」インターフェースで定義されている「getRequestURI」メソッドを使います。 getRequestURI public java.lang.String getRequestURI() Returns the part of this request's URL from the protocol name up to the query string in the first line of the HTTP request. The web container does not decode this String. For example: Fir
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く