<%-- 
    Document   : parameters
    Created on : 2011-06-08, 18:41:06
    Author     : Pawel
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body>
        <h1>Parametry</h1>
        <p>Metoda: <%= request.getMethod()%></p>
        <p>Zapytanie: <%= request.getQueryString()%></p>
        <h2>Prosta enumeracja</h2>
        <table cellpadding="4" cellspacing="1" border="1">
            <%
                java.util.Enumeration<String> e = request.getParameterNames();
                while (e.hasMoreElements()) {
                    String s = e.nextElement();
                    out.println("<tr><td>" + s + "</td><td>" + request.getParameter(s) + "</td></tr>");
                }
            %>
        </table>

        <h3>Po nazwach</h3>

        <table cellpadding="4" cellspacing="1" border="1">
            <tr><td>Imię:</td><td><%= request.getParameter("imie") != null ? request.getParameterMap().get("imie")[0] : ""%></td>
            <tr><td>Nazwisko:</td><td><%= request.getParameter("nazwisko") != null ? request.getParameterMap().get("nazwisko")[0] : ""%></td>
            <tr><td>Miasta:</td><td><%= request.getParameter("miasta") != null ? request.getParameterMap().get("miasta")[0] : ""%></td>
        </table>


        <h3>Formularz</h3>
        <form action="parameters.jsp?imie=kicha" name="theForm" method="post">
            <table cellpadding="4" cellspacing="1" border="0">
                <tr><td>Imię:</td><td><input type="text" name="imie" value='<%= request.getParameter("imie") != null ? request.getParameter("imie") : ""%>' /></td></tr>
                <tr><td>Nazwisko:</td><td><input type="text" name="nazwisko" value='<%= request.getParameter("nazwisko") != null ? request.getParameter("nazwisko") : ""%>' /></td></tr>
                <tr><td>Miasta:</td><td><select name="miasta" multiple="true" ><option value="0">Warszawa</option><option value="1">Wrocław</option><option value="2">Kraków</option></select></td></tr>
                <tr><td colspan="2"><input type="submit" value="Wyślij" /></td></tr>
            </table>
        </form>
    </body>
</html>
