private String processDelete(String parameter) { if (parameter != null) { try { Item read = newItemDao.read(Long.valueOf(parameter)); if (read != null) { newItemDao.delete(read); return "delete: " + read.toString(); } } catch (Exception e) { e.printStackTrace(); } } return null; }
private String processCreate(String parameter) { if (parameter != null) { Item create = newItemDao.create(new Item(parameter, parameter, null)); return "create: " + create.toString(); } return null; }
@Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { String processGet = processGet(req.getParameter("get")); StringBuilder all = new StringBuilder(); List<Item> findAll = newItemDao.findAll(); for (Item i : findAll) { all.append(i).append("<br/>"); } writePage(resp, null, null, processGet, all); }