Exemplo n.º 1
0
  protected void doPost(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {

    response.setContentType("html/text");
    PrintWriter out = response.getWriter();

    String viewitem = request.getParameter("name");
    System.out.println(viewitem);
    UserDAO userDAO = new UserDAO();
    boolean isertDummyItemsOrNot = false;

    if (userDAO.itemCount() > 0) {
      isertDummyItemsOrNot = true;
    } else {
      isertDummyItemsOrNot = userDAO.insertDummyItems();
    }

    if (isertDummyItemsOrNot) {
      Item it = userDAO.itemFatch(viewitem);
      System.out.println("Heloo " + it);
      request.setAttribute("abc", it.getItemID());
      request.setAttribute("bcd", it.getItemName());
      request.setAttribute("efc", it.getPrice());
      request.setAttribute("img", (String) hm.get(it.getItemID()));
      RequestDispatcher rd = request.getRequestDispatcher("Item.jsp");
      rd.forward(request, response);
    } else {
      RequestDispatcher rd = request.getRequestDispatcher("ItemDesc.jsp");
      rd.forward(request, response);
      System.out.println("no");
    }
  }
Exemplo n.º 2
0
 public boolean equals(Object o) {
   if (o instanceof Item) {
     Item i = (Item) o;
     return i.toString().equals(this.toString());
   } else {
     return false;
   }
 }
Exemplo n.º 3
0
 @Override
 public boolean addItem(Item it) throws Exception {
   if (itemList.size() < maxItemCnt) {
     if (it.getProperties().toLowerCase().contains("плоский")) {
       maxItemCnt += 1;
       return super.addItem(it); // To change body of generated methods, choose Tools | Templates.
     } else {
       throw new ItemStoreException("в стопку можно добавлять только плоские предметы");
     }
   } else {
     throw new ItemStoreException(
         "в эту стопку нельзя складывать больше " + maxItemCnt + " предмета(ов)");
   }
 }