Me ajudem preciso controlar essa enquete .
Eu precisaria implementar essa enquete com um controle, do tipo o mesmo usuario que acabou de voltar, não poderá votar novamente.
"Deverá aparecer uma menssagem de controle." - Usuarioa X já voltou.
HTML
html>
<head>
<title>pesquisa </title>
</head>
<body bgcolor="#000000" text="#FFFFFF">
<h1>Pesquisa</h1>
<form name=“form_pesquisa” action=“enquete2.jsp” method=“POST”>
Informe seu nome:
<input name=“eNome” size=“20”>
<h4> Qual a aula que voce mais detesta na faculdade:</h4>
<select name=“aulas”>
<option value=“0”>WEB</option>
<option value=“1”>ALGORITMOS</option>
<option value=“2”>JAVA</option>
<option value=“3”>ESTATISTICA</option>
<option value=“4”>ADMINISTRAÇÃO</option>
</select><br><br>
<center><input type="submit" value="Enviar resposta"></center>
</form>
</body>
</html>
JSP
<%@page contentType=“text/html” import=“java.io.*”%>
<html>
<head>
<title>jsp page</title>
</head>
<body bgcolor="#000000" text="#FFFFFF" vlink="#003399">
<%
int opc[]=new int[5];
String nomOpc[]={“WEB”,“ALGORITMOS”,“JAVA”,“ESTATISTICA”,“ADMINISTRAÇÃO”};
String nomCor[]={“marrom”,“azul”,“purpura”,“ouro”,“verde”};
int total=1;
String nomArq=“resultado.txt”;
//le o arquivo
File arq= new File(nomArq);
if(arq.exists()){
BufferedReader br= new BufferedReader(new FileReader(nomArq));
String lin;
int i=0;
while((lin=br.readLine())!=null){
opc[i]=Integer.parseInt(lin);
total+= opc[i];
i++;
}
br.close();
}else{//arq vazio
for(int i=0;i<opc.length;i++)
opc[i]=0;
}
int indice=Integer.parseInt(request.getParameter(“aulas”));
opc[indice]+=1;
//monta o grafico
for (int i = 0; i < opc.length; i++) {
out.println("<img src=‘image\" + nomCor[i] + ".gif’ width = " + ((100 * opc[i])/total) + “heigth=10>”
// “<img src = ‘’ width=” + (100 - (100 * opc[i] / total )) + " heigth=10>");
);
out.println(nomOpc[i] + " - " + opc[i] + " Votos. <br>");
}
//regrava o arquivo
PrintWriter saida= new PrintWriter(new FileWriter(nomArq));
for(int i=0;i<opc.length;i++)
saida.println(opc[i]);
saida.close();
%>
clique aqui para voltar
a pagina principal.
</body>
</html>