私はフォームを持っています。タイマーがフォームに達すると、自動的にサーブレットにデータベースを更新するようにリダイレクトされます。私の問題は、javascriptがサーブレットにウィンドウをリダイレクトする場合です。私のrequest.getParameterはnullです。JSP getParameterの問題
function verify(f,whichCase){
if(whichCase == "Submit"){
msg = "Are you sure that you want to submit this test?";
var i = confirm(msg)
if(i){
parent.window.location = "sindex.jsp"
}
return i;
}
}
私は自分のJSPでiframeを取得しているため、これを行っています。タイマーアップデートの問題はiframeを使用する必要があります。だから、タイムアップまたはユーザーがparent.window.locationが、私は、ユーザーがタイミング以内に送信ボタンをクリックしたとき、それは利用者の確認を提出できるように確認する機能をトリガするマイフォーム親ウィンドウ
<form method="POST" action="${pageContext.request.contextPath}/TestServlet" onSubmit="return verify(this,whichPressed)">
をリフレッシュさせることができ提出クリックしたとき。だから私のTestServletの中で私はこれを持っているので、javascriptのリダイレクトrequest.getParameter( "答え")これは私のnullを返してください。以下は
protected void doPost(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
if (request.getParameter("Submit") != null) {
String ans = request.getParameter("answer");
Answer a = new Answer(ans, no);
aa.CreateAnswer(an,t.getTestCode(),username);
RequestDispatcher rd = request.getRequestDispatcher("/sindex.jsp");
rd.forward(request, response);
}
}
はタイムアップdoGetメソッド
if((mins == 0) && (secs == 0)) {
window.alert("Time is up. Press OK to submit the test."); // change timeout message as required
var sUrl = "TestServlet";
parent.window.location = sUrl // redirects to specified page once timer ends and ok button is pressed
} else {
cd = setTimeout("redo()",1000);
}
こんにちは、そのフォームがiframeの内側にあるためです – user236501