private void validateValues() { if ((title.equals("")) || (title == null)) { validationErrors.insertNewErrorMessage("Title is empty!"); } if ((post.equals("")) || (post == null)) { validationErrors.insertNewErrorMessage("Post is empty!"); } }
/** * Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods. * * @param request servlet request * @param response servlet response * @throws ServletException if a servlet-specific error occurs * @throws IOException if an I/O error occurs */ protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { Thread thread = null; ThreadController threadController = new ThreadController(); parseValues(request); validateValues(); thread = new Thread(null, created, locked, post, title); thread.setAuthor(author); if (!validationErrors.isEmpty()) { request.setAttribute("validationErrors", validationErrors); request.getRequestDispatcher("submissionerror.jsp").forward(request, response); } else { try { threadController.create(thread); response.sendRedirect("index.jsp"); } catch (Exception e) { Logger.getLogger(CreateThread.class.getName()).log(Level.SEVERE, null, e); } } }