1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
| public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
String nombre1 = request.getParameter("nombre1");
String nombre2 = request.getParameter("nombre2");
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println("<html><head><title> mon servlet </title></head>");
out.println("<body> le résultat est </body>");
int nb1=Integer.parseInt(nombre1);
int nb2=Integer.parseInt(nombre2);
out.println("la somme de:"+nb1+"et de"+nb2+"est"+(nb1+nb2));
out.println("</body>");
out.println("</html>");
}
/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
}
} |
Partager