我有一个表单要求用户输入ID。此表单发送到一个servlet,该servlet检查数据库以查看用户是否存在。如果用户存在,那么它会发回我们的订购项目。有序项目作为数组列表返回。然后这个数组列表将重定向到jsp文件,以便在网页上显示它。用户可以有一个以上的顺序,因此数组列表大小可以有所不同。如何获取数组列表大小,以便我可以在数组列表中显示每个项目?我不想使用JSTL。
的index.jsp:
JSP Page/*function signin(id, id2) {
document.getElementById(id).style.display = 'block';
document.getElementById(id2).style.display = 'none';
//document.getElementById(id3).style.display = 'none';
}*/
Login
placeholder="UserID">
style="display:none;">
Sign Up
placeholder="User ID">
placeholder="First Name">
placeholder="Last Name">
placeholder="Street">
placeholder="City">
--%>
FindUser.java:
public class FindUser extends HttpServlet {
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse
response) throws ServletException, IOException {
String sID = request.getParameter("txtCustID");
String url = ("admin/UserFound.jsp");
try {
Users one = UserDAO.findUser(sID);
request.setAttribute("theCustomer", one);
if (one.getFirstName().equals("none")) {
url = "admin/UserNotFound.jsp";
}
ArrayList user_order = UserDAO.findOrder(sID);
request.setAttribute("theOrder", user_order);
response.sendRedirect(url);
//RequestDispatcher rd = request.getRequestDispatcher(url);
//rd.forward(request, response);
} catch (ClassNotFoundException e) {
System.err.print("Failed to load Driver");
System.err.print(e);
} catch (SQLException e) {
System.err.print("SQL Error" + e);
System.err.print("SQL State: " + e.getSQLState());
System.err.print("Error Code: " + e.getErrorCode());
} catch (Exception e) {
System.err.println(e);
}
}
UserFound.jsp:
Document : CustomerFound
Created on : Nov 15, 2014, 9:40:47 PM
Author : mississauga
--%>
JSP PageFirst word is: ${theOrder[x].getBoxes()}
style="display:none;">
Login
placeholder="UserID">
--%>
}