| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 
 | <%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">
 
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body>
        <%
        int n = 1;
        String s = Integer.toString(n);
        Cookie[]cookies = request.getCookies();
        if(cookies!=null){
            for(int i=0; i<cookies.length; i++){
                if(cookies[i].getName().equals("compteur")){
                    s = cookies[i].getValue();
                    n = Integer.parseInt(s);
                    n = n+1;
                    s = Integer.toString(n);
                    Cookie compteur = new Cookie("compteur", s);
                    compteur.setMaxAge(3600);
                    response.addCookie(compteur);
                }
            }
        }
        else{
            Cookie compteur = new Cookie("compteur", s);
            compteur.setMaxAge(3600);
            response.addCookie(compteur);
        }      
        %>
        Cette page a ete affichee <%=s%> fois.
    </body>
</html> | 
Partager