%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
Thank You!
<%@ page import="servlets.SurveyServlet"%>
<%
String animalNames[] = servlets.SurveyServlet.animalNames;
int votes[] = (int[]) request
.getAttribute(SurveyServlet.votesAttribute/*"votes"*/);
String formattedPercentages[] = (String[]) request
.getAttribute(SurveyServlet.percentageAttribute /*"percentages"*/);
int totalVotes = 0;
%>
Parameters
Thank you for your input!
Results:
Animal |
# of Votes |
% of Votes |
<%
for (int i = 0; i < animalNames.length; i++) {
%>
<%=animalNames[i]%> |
<%=votes[i]%> |
<%=formattedPercentages[i]%> |
<%
totalVotes += votes[i];
%>
<%
}
%>
Again with JSTL:
Animal |
# of Votes |
% of Votes |
${animal.name} |
${animal.votes} |
${animal.fmtVotes} |
Total Votes:
<%=totalVotes%>
Vote Again