JBOSSでサーバーを実行しています。すべてのリクエストをリッスンするものがFilter
あります。つまり、すべてのリクエストがフィルターに送られ、Servlets
ここから他のリクエストに渡されます。これに気づきました:
次のコードを使用すると、フィルターのみが呼び出されますが、制御はそれぞれのサーブレットに渡されません(フィルターは、を使用して印刷すると正しいサーブレットを印刷しrequest.getRequestURI()
ます。また、リクエストヘッダーの正しい値をusername
印刷します。 password
)
HttpURLConnection connection=gs.getconnection("send_user_detail");
connection.setRequestProperty("user", gs.get_login_id());
connection.setRequestProperty("password", gs.get_pass());
connection.setRequestProperty("timezone", TimeZone.getDefault().getDisplayName());
connection.connect();
しかし、次のコードを使用すると、制御はそれぞれに渡され、Servlet
正常に機能します。
HttpURLConnection connection=gs.getconnection("send_user_detail");
connection.setRequestProperty("user", gs.get_login_id());
connection.setRequestProperty("password", gs.get_pass());
connection.setRequestProperty("timezone", TimeZone.getDefault().getDisplayName());
//connection.connect();
ObjectOutputStream out=new ObjectOutputStream(connection.getOutputStream());
out.writeObject("string"); //some random string not used in the servlet
したがって、OutputStreamに何かを書き込んだ場合にのみ、制御がサーブレットに渡されます。しかし、を使用するとconnection.connect()
、それでもフィルターに到達し、要求されたの正しい名前を出力しますServlet
。理由は何ですか?