我对 JSP 和 servlet 完全陌生,所以这个问题可能真的很不寻常或很容易解决!我正在尝试获取id=creditcard
和id=expirationDate
输入字段的值!在 serverlet 的函数中检查字段是否与数据库中的数据匹配,如下所示:
servlet 中的 HTML:
out.println("<html>");
out.println("<head>");
out.println("<title>Make payment</title>");
out.println("<script type='text/javascript' src='js/jquery-1.5.2.min.js'></script>");
out.println("<script type='text/javascript' src='js/payment.js'></script>");
out.println("<link type='text/css' href='css/style.css' rel='Stylesheet' />");
out.println("</head>");
out.println("<body>");
out.println("<div class='bg-light' style='width: 200px; height: 200px; position: absolute; left:50%; top:50%; margin:-100px 0 0 -100px; padding-top: 40px; padding-left: 10px;'>");
out.println("<input id='reservationID' style='display: none' value='"+rb.reservationID+"' />");
out.println("<div>Credit Card Number : </div>");
out.println("<div><input id='creditcard' onKeyPress='return checkIt(event);' type='text' name='creditcard' maxlength='16' /></div>");
out.println("<div>ExpirationDate : </div>");
out.println("<div><input id='expirationDate' type='text' onKeyPress='return checkIt(event);' name='expirationDate' maxlength='4' /></div>");
out.println("<span style='font-size: 75%;'>"+Error+"</span>");
out.println("<div><input type='button' name='buttonsave' value='Make Payment' onclick='makePayment("+rb.reservationID+");' /></div>");
out.println("<div><input type='button' name='buttoncancel' value='Cancel Payment' onclick='cancelPayment("+rb.reservationID+");' /></div>");
out.println("</div>");
out.println("</body>");
out.println("</html>");
我正在使用 servlet 中的函数来检查输入并在错误时显示错误out.println("<span style='font-size: 75%;'>"+Error+"</span>")
。
小服务程序功能:
String Error= "";
bolean check = us.checkCC(userID, creditno, expiration); // i need the values here!
....
提前致谢!