public void doPost(HttpServletRequest req, HttpServletResponse res) { try { String buildingname = checkNull(req.getParameter("buildingname")); String streetname = checkNull(req.getParameter("streetname")); String unitno = checkNull(req.getParameter("unitno")); String block = checkNull(req.getParameter("block")); String postalcode = checkNull(req.getParameter("postalcode")); ADDRESSDao.INSTANCE.add(new Addresses(buildingname, unitno, block, streetname, postalcode)); res.setHeader("Refresh", "2; /"); res.getWriter().println("All okay!"); } catch (IOException e) { e.printStackTrace(); } }