package com.llgc; import java.io.IOException; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.nio.charset.StandardCharsets; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; /** * Servlet implementation class Servlet */ @WebServlet ("/Servlet") public class Servlet extends HttpServlet { /** * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse * response) */ protected void doGet (HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setCharacterEncoding ("UTF-8"); PrintWriter out = response.getWriter (); response.setContentType ("text/html"); out.println (""); out.println (""); out.println ("
"); out.println (""); out.println ("");
if (15 % 2 == 0)
{
out.print ("15 est un nombre pair.");
}
else
{
out.print ("15 est un nombre impair.");
}
out.println ("
");
switch (16 % 2)
{
case 0:
out.print ("16 est un nombre pair.");
break;
default:
out.print ("16 est un nombre impair.");
break;
}
out.println ("