Cours JSP 4
Exemple Servlets
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class ExempleServlet extends HttpServlet {
public void doGet(HttpServletRequest req, HttpServletResponse
res)
throws ServletException, IOException {
// positionnement du type de contenu
res.setContentType("text/html");
// écriture du contenu
PrintWriter out = res.getWriter();
out.println("<HTML>"); out.println("<HEAD>");
out.println("<TITLE>ExempleServlet</TITLE>");
out.println("</HEAD>"); out.println("<BODY>");
out.println("<H1 align="center">ExempleServlet</H1>");
out.println("</BODY>");
out.println("</HTML>");
out.close();
}
}