Boa tarde pessoal!
Estou começando com JSP e já me deparei com um problema; como exibir imagens?
Peguei esse exemplo em um livro porem as imagens não aparecem.
Vcs podem me ajudar?
<%@page contentType = "text/html" import = "java.io.*"%>
<html>
<head>
<title>JSP Page</title>
</head>
<body>
<%
int[] opc = new int[5];
String[] nomOpc = {"Vinho", "Cerveja", "Whiskey", "Refrigerante", "Água"};
String[] nomCor = {"amarelo", "azul", "marom", "verde", "vermelho"};
int total = 1;
String nomArq = "resutado.txt";
//lê arquivo
File arq = new File(nomArq);
if(arq.exists()){//se arq ja foi gravado
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("eBebida"));
opc[indice] += 1;
//monta grafico
for(int i = 0; i < opc.length; i++){
out.println("<img src='image\\" + nomCor[i] + ".gif' width = "+
((100 * opc[i]) / total) + "height = 10>" +
"<img src = '' width = " + (100 - ((100 * opc[i])/total)) + "height = 10>");
out.println(nomOpc[i] + " - " + opc[i] + "Votos.<br>");
}
//regrava arquivo
PrintWriter saida = new PrintWriter (new FileWriter(nomArq));
for(int i = 0; i< opc.length; i++)
saida.println(opc[i]);
saida.close();
%>
</body>
</html>