package com.llgc; import java.io.IOException; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.nio.charset.StandardCharsets; import javax.servlet.ServletConfig; 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 Servlet3 */ @WebServlet ("/Servlet3") public class Servlet3 extends HttpServlet { @Override public void init (ServletConfig config) throws ServletException { BeanPersonne pers = new BeanPersonne (); pers.setTaille (123); config.getServletContext ().setAttribute ("beanApp", pers); super.init (config); } /** * @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 (); BeanPersonne pers = new BeanPersonne (); request.getSession (true).setAttribute ("beanSession", pers); response.setContentType ("text/html"); out.println (""); out.println (""); out.println ("
"); out.println (""); out.println ("