/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package servlets; import java.io.*; import java.net.*; import javax.servlet.*; import javax.servlet.http.*; /** * * @author javamobile */ public class Tervitaja extends HttpServlet { /** * Processes requests for both HTTP GET and POST methods. * @param request servlet request * @param response servlet response */ protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html;charset=UTF-8"); PrintWriter out = response.getWriter(); try { out.println(""); out.println(""); out.println("Servlet Tervitaja"); out.println(""); out.println(""); out.println("

Minu Servlet Tervitaja at " + request.getContextPath () + "

"); out.println("
"); out.println(" "); out.println(KujundusAbi.looRippmenyy("tehe", new String[]{"+", "-", "*", "/"}, request.getParameter("tehe"))); out.println(" "); //Asendage korrutusmärk tehtevalikuga out.println(""); if(request.getParameter("arv1")!=null){ Arvutaja a=new Arvutaja(request.getParameter("arv1"), request.getParameter("arv2")); out.println(a.tehe(request.getParameter("tehe"))); //Näidake vastus vastavalt tehtele } out.println(""); out.println(""); out.println("
"); out.println(""); out.println(""); } finally { out.close(); } } // /** * Handles the HTTP GET method. * @param request servlet request * @param response servlet response */ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { processRequest(request, response); } /** * Handles the HTTP POST method. * @param request servlet request * @param response servlet response */ protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { processRequest(request, response); } /** * Returns a short description of the servlet. */ public String getServletInfo() { return "Short description"; } // }