Lab 5 Web Services/SpellCheckService/src/java/clientservlet/SpellCheckServlet.java
/**
     * 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
     */
Processes requests for both HTTP
GET and
POST 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
Processes requests for both HTTP GET and POST 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 {
        response.setContentType("text/html;charset=UTF-8");
       try (PrintWriter out = response.getWriter()) {
    String TextArea1 = request.getParameter("TextArea1");
    java.lang.String bodyText = TextArea1;
    com.cdyne.ws.DocumentSummary doc = checkTextBodyV2(bodyText);
    String allcontent = doc.getBody();
    int no_of_mistakes = doc.getMisspelledWordCount();
    List allwrongwords = doc.getMisspelledWord();
    out.println("<html>");
    out.println("<head>");
    out.println("<title>Spell Checker Report</title>");
    out.println("</head>");
    out.println("<body>");
    out.println("<h2><font color='red'>Spell Checker Report</font></h2>");
    out.println("<hr><b>Your text:</b> \"" + allcontent + "\"" + "<p>");
    for (int i = 0; i < allwrongwords.size(); i++) {
        String onewrongword = ((Words) allwrongwords.get(i)).getWord();
        int onewordsuggestioncount = ((Words) allwrongwords.get(i)).getSuggestionCount();
        List allsuggestions = ((Words) allwrongwords.get(i)).getSuggestions();
        out.println("<hr><p><b>Wrong word:</b><font color='red'> " + onewrongword + "</font>");
        out.println("<p><b>" + onewordsuggestioncount + " suggestions:</b><br>");
        for (int k = 0; k < allsuggestions.size(); k++) {
            String onesuggestion = (String) allsuggestions.get(k);
            out.println(onesuggestion);
        }
    }
    out.println("<hr>");
    out.println("<font color='red'><b>Summary:</b> " + no_of_mistakes + " mistakes (");
    for (int i = 0; i < allwrongwords.size(); i++) {
        String onewrongword = ((Words) allwrongwords.get(i)).getWord();
        out.println(onewrongword);
    }
    out.println(").");
    out.println("</font>");
    out.println("</body>");
    out.println("</html>");
} 
    }
protected void processRequest ( HttpServletRequest request , HttpServletResponse response ) throws ServletException , IOException { response . setContentType ( "text/html;charset=UTF-8" ) ; try ( PrintWriter out = response . getWriter ( ) ) { String TextArea1 = request . getParameter ( "TextArea1" ) ; java . lang . String bodyText = TextArea1 ; com . cdyne . ws . DocumentSummary doc = checkTextBodyV2 ( bodyText ) ; String allcontent = doc . getBody ( ) ; int no_of_mistakes = doc . getMisspelledWordCount ( ) ; List allwrongwords = doc . getMisspelledWord ( ) ; out . println ( "<html>" ) ; out . println ( "<head>" ) ; out . println ( "<title>Spell Checker Report</title>" ) ; out . println ( "</head>" ) ; out . println ( "<body>" ) ; out . println ( "<h2><font color='red'>Spell Checker Report</font></h2>" ) ; out . println ( "<hr><b>Your text:</b> \"" + allcontent + "\"" + "<p>" ) ; for ( int i = 0 ; i < allwrongwords . size ( ) ; i ++ ) { String onewrongword = ( ( Words ) allwrongwords . get ( i ) ) . getWord ( ) ; int onewordsuggestioncount = ( ( Words ) allwrongwords . get ( i ) ) . getSuggestionCount ( ) ; List allsuggestions = ( ( Words ) allwrongwords . get ( i ) ) . getSuggestions ( ) ; out . println ( "<hr><p><b>Wrong word:</b><font color='red'> " + onewrongword + "</font>" ) ; out . println ( "<p><b>" + onewordsuggestioncount + " suggestions:</b><br>" ) ; for ( int k = 0 ; k < allsuggestions . size ( ) ; k ++ ) { String onesuggestion = ( String ) allsuggestions . get ( k ) ; out . println ( onesuggestion ) ; } } out . println ( "<hr>" ) ; out . println ( "<font color='red'><b>Summary:</b> " + no_of_mistakes + " mistakes (" ) ; for ( int i = 0 ; i < allwrongwords . size ( ) ; i ++ ) { String onewrongword = ( ( Words ) allwrongwords . get ( i ) ) . getWord ( ) ; out . println ( onewrongword ) ; } out . println ( ")." ) ; out . println ( "</font>" ) ; out . println ( "</body>" ) ; out . println ( "</html>" ) ; } }
Processes requests for both HTTP
 <code>GET</code> and
 <code>POST</code> methods.
Processes requests for both HTTP <code > GET< / code > and <code > POST< / code > methods .
//Get the TextArea from the web page //Initialize WS operation arguments //Process result //From the retrieved document summary, //identify the number of wrongly spelled words: //From the retrieved document summary, //identify the array of wrongly spelled words: //Display the report's name as a title in the browser's titlebar: //Display the report's name as a header within the body of the report: //Display all the content (correct as well as incorrectly spelled) between quotation marks: //For every array of wrong words (one array per wrong word), //identify the wrong word, the number of suggestions, and //the array of suggestions. Then display the wrong word and the number of suggestions and //then, for the array of suggestions belonging to the current wrong word, display each //suggestion: //Display a line after each array of wrong words: //Summarize by providing the number of errors and display them: