Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package cl.adl.ejemplo;
- import java.io.IOException;
- import java.io.PrintWriter;
- import javax.servlet.ServletException;
- import javax.servlet.annotation.WebServlet;
- import javax.servlet.http.Cookie;
- import javax.servlet.http.HttpServlet;
- import javax.servlet.http.HttpServletRequest;
- import javax.servlet.http.HttpServletResponse;
- /**
- * Servlet implementation class RecuperaCookie
- */
- @WebServlet("/RecuperaCookie")
- public class RecuperaCookie extends HttpServlet {
- protected void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException{
- Cookie[] cookies = request.getCookies();
- PrintWriter print = response.getWriter();
- print.println("<html><body>");
- print.println("<h2><i>Cookie recuperada correctamente:</i></h2><br>");
- for(int i = 0; i < cookies.length; i++) {
- print.println("Id de la cookie: <strong>"+ cookies[i].getValue() + "</strong>");
- print.println("<br>");
- print.println("Valor de la cookie: <strong>" + cookies[i].getName()+"</strong>");
- print.println("<br>");
- }
- print.println("</body></html>");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement