How to get array list size in java jsp?

后端 未结 4 794
一向
一向 2020-12-17 08:31

I have a form that ask for user to enter ID. This form is send to a servlet which checks database to see if user exist. If the user exists then it sends me back their ordere

4条回答
  •  北荒
    北荒 (楼主)
    2020-12-17 09:06

    you should set scope of your UserFound.jsp to request.

    ArrayList orderList = (ArrayList )  request.getAttribute("theOrder");
    
    
      <% If(orderList != null) {%> <% for(String orderName : orderList ) { %>
    • <%= orderName %>
    • <% } %> <% }else{ %> No Order Found <% } %>

    OR

    ArrayList orderList = (ArrayList )  request.getAttribute("theOrder");
    
      <% If(orderList != null) {%> <% for(int orderNum =0;i< orderList.size();++orderNum ) { %>
    • <%= orderList.get(orderNum )%>
    • <% } %> <% }else{ %> No Order Found <% } %>

提交回复
热议问题