私はこの問題が非常に困惑している (しかし興味深い) ことを発見したので、ここにいる人々に洞察を求めたいと思います。
私は JSP と関連技術を独学で学んできました。私がやろうとしているのは、JSP からサーブレットにパラメーターを取得し、If() で使用することです。これが私のコーディングの一部です。
if ((request.getParameter("ID_A") != null || request.getParameter("Password_A") != null) &&
(request.getParameter("ID_B") != null || request.getParameter("Password_B") != null)) {
errorMessage = "Information is detected for the both side";
request.setAttribute("errorMessage", errorMessage);
request.getRequestDispatcher("4_enter_personal_info.jsp").forward(request, response);
} // Other conditions...
これはJSPの一部です(前のステップ)
<form action="PersonalInfor_to_confirmation_servlet" method="POST">
<h2>For an existing customer</h2>
<p>Customer ID</p>
<input type="text" name="ID_A" value="" />
<p>Password</p>
<input type="text" name="Password_A" value="" />
<br>
<h2>For a new customer</h2>
<p>Set your customer ID</p>
<input type="text" name="ID_B" value="" />
<p>Set your password</p>
<input type="text" name="Password_B" value="" />
//There are other lines
</form>
クライアントが両側に情報を入力した場合 ( )、 JSPFor an existing customer/For a new customer
に上記のメッセージが表示されるようにしています。"Information is detected for the both side"
ただし、すべてのテキスト ボックスが空白であっても、エラー メッセージが表示されます。したがって、request.getParameter( )
上記のすべてのメソッドには、空にしても null 値は含まれません。
他のアルゴリズムを思いついたとしても、この現象が起こる理由を知りたいです。
アドバイスをいただければ幸いです。