@Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {

        Matcher matcher;
         
        //clean the inputs using regular expressions
        // Compile regular expression
        Pattern pattern = Pattern.compile("[;:,#&'\".!?]");
        // Replace all occurrences of pattern in input
        matcher = pattern.matcher(request.getParameter ("sender"));
        String clean_author = matcher.replaceAll("|");
        matcher = pattern.matcher(request.getParameter ("title"));
        String clean_title = matcher.replaceAll("|");
        matcher = pattern.matcher(request.getParameter ("message"));
        String clean_message = matcher.replaceAll("|");
        
        //open the DBMS and insert the record
        
        
        RequestDispatcher view;
        try {
            String id = request.getParameter("id");
            if ( id == null ) {
                SsMessage message = new SsMessage();
                message.setAuthor(clean_author);
                message.setTitle(clean_title);
                message.setPtime(new Date());
                message.setMessage(clean_message);
                ssMessageFacade.create(message);
            } else {
                SsMessage message = ssMessageFacade.find(Integer.parseInt(id));
                message.setAuthor(clean_author);
                message.setTitle(clean_title);
                message.setPtime(new Date());
                message.setMessage(clean_message);
                ssMessageFacade.edit(message);
            }
            
            request.setAttribute("clean_author", clean_author);
            request.setAttribute("clean_title", clean_title);
            request.setAttribute("clean_message", clean_message);
            
            int connectionTime = 1000; // connection.getTime()-start.getTime()
            int insertTime = 750; // process.getTime()-connection.getTime()
            int closeTime = 250; // close.getTime()-process.getTime()
            request.setAttribute("connection_time", connectionTime);
            request.setAttribute("insert_time", insertTime);
            request.setAttribute("close_time", closeTime);
            view = request.getRequestDispatcher("messageSuccess.jsp");
        } catch (Exception ex ) {
            request.setAttribute("sender", request.getParameter("sender"));
            request.setAttribute("message", request.getParameter("message"));
            view = request.getRequestDispatcher("messageError.jsp");            
        }
        view.forward(request, response);
    }