Пример #1
0
  @Override
  public void doPost(HttpServletRequest req, HttpServletResponse resp)
      throws ServletException, IOException {
    // Map for storing messages.
    Map<String, String> messages = new HashMap<String, String>();
    req.setAttribute("messages", messages);

    // Retrieve and validate id.
    {
      // Create the School
      String name = req.getParameter("name");
      String participation = req.getParameter("participation");
      String contacted = req.getParameter("contacted");
      String pocname = req.getParameter("pocname");
      String pocemail = req.getParameter("pocemail");
      String location = req.getParameter("location");

      try {
        Schools school =
            new Schools(
                name,
                (Boolean.parseBoolean(participation)),
                (Boolean.parseBoolean(contacted)),
                pocname,
                pocemail,
                location);
        school = schoolsDao.create(school);
        messages.put("success", "Successfully created School " + name);
      } catch (SQLException e) {
        e.printStackTrace();
        throw new IOException(e);
      }
    }

    req.getRequestDispatcher("/CreateSchool.jsp").forward(req, resp);
  }
Пример #2
0
 @Override
 public void init() throws ServletException {
   schoolsDao = SchoolsDao.getInstance();
 }