Lab 5 Web Services/CalculatorWSServletClient/src/java/org/me/calculator/client/ClientServlet.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");
        PrintWriter out = response.getWriter();
        try {          
            /* TODO output your page here. You may use following sample code. */
            out.println("<!DOCTYPE html>");
            out.println("<html>");
            out.println("<head>");
            out.println("<title>Servlet ClientServlet</title>");            
            out.println("</head>");
            out.println("<body>");
            out.println("<h1>Servlet ClientServlet at " + request.getContextPath() + "</h1>");
            out.println("</body>");
            out.println("</html>");
            out.println("<h1>Servlet ClientServlet at " + request.getContextPath () + "</h1>");
            try {
                 int i = 3;
                 int j = 4;
                 int result1 = add(i, j);
                 out.println("Result of addition = " + result1);
                 int result2 = subtract(i, j);
                 out.println("Result of subtraction = " + result2);
                 int result3 = multiply(i, j);
                 out.println("Result of multiplication = " + result3);
                 int result4 = divide(i, j);
                 out.println("Result of division = " + result4);
        } catch (Exception ex) {
            out.println("Exception: " + ex);
        }
        out.println("</body>");
        out.println("</html>");
        } finally {            
            out.close();
        }
    }
protected void processRequest ( HttpServletRequest request , HttpServletResponse response ) throws ServletException , IOException { response . setContentType ( "text/html;charset=UTF-8" ) ; PrintWriter out = response . getWriter ( ) ; try { /* TODO output your page here. You may use following sample code. */ out . println ( "<!DOCTYPE html>" ) ; out . println ( "<html>" ) ; out . println ( "<head>" ) ; out . println ( "<title>Servlet ClientServlet</title>" ) ; out . println ( "</head>" ) ; out . println ( "<body>" ) ; out . println ( "<h1>Servlet ClientServlet at " + request . getContextPath ( ) + "</h1>" ) ; out . println ( "</body>" ) ; out . println ( "</html>" ) ; out . println ( "<h1>Servlet ClientServlet at " + request . getContextPath ( ) + "</h1>" ) ; try { int i = 3 ; int j = 4 ; int result1 = add ( i , j ) ; out . println ( "Result of addition = " + result1 ) ; int result2 = subtract ( i , j ) ; out . println ( "Result of subtraction = " + result2 ) ; int result3 = multiply ( i , j ) ; out . println ( "Result of multiplication = " + result3 ) ; int result4 = divide ( i , j ) ; out . println ( "Result of division = " + result4 ) ; } catch ( Exception ex ) { out . println ( "Exception: " + ex ) ; } out . println ( "</body>" ) ; out . println ( "</html>" ) ; } finally { out . close ( ) ; } }
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 .