<%@ page import="java.util.Map" %>
<%@ page import="java.io.PrintWriter" %>
<%@ page import="java.util.Set" %>
<%--
  Created by IntelliJ IDEA.
  User: K_A_Volchica
  Date: 13.07.2015
  Time: 17:17
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Echoing HTML Request Parameters</title>
</head>
<body>
<h3>Choose an author:</h3>
<form method="get">
    <input type="radio" name="author" value="Tan Ah Teck">Tan
    <input type="radio" name="author" value="Mohd Ali">Ali
    <input type="radio" name="author" value="Kumar">Kumar
    <input type="submit" value="Query">
</form>

<%
    PrintWriter out = response.getWriter();
    String sCommand=(String)request.getParameter("author");
    Map<String,String> result;
    if (result.containsValue(session.getAttribute("username")))
    {

        out.println("<div style='font-weight:bold;'>Нельзя повторно голосовать</div>");
    }
    else
    {
        result.put(sCommand,session.getAttribute("username"));
    }

%>
<h3>You have selected author(sCommand). Results:</h3>
<ul>
    <%
        {
        int a=0;
        Set keys = result.keySet();
        for (String key: keys) {
            if (result.containsKey(key)) {
                a++;
                out.println("<div style='font-weight:bold;'>считаем количество голосовавших за автора " + key + "</div>");
            }


        }
    %>
</ul>
<a href="<%= request.getRequestURI() %>">BACK</a>
<%
    }
%>
</body>
</html>
