Am trying to retrieve the data submitted from the HTML from in a servlet.Am using netbeans and am trying to get the enumeration returned by getAttributes(). The html is
   <html>
    <body>
        <center>
        <form name="Form1" action="http://localhost:8080/DemoWeb/TwoParServlet">
                <B>Color:</B>
                <select name="color" size="1">
                    <option value="Red">Red</option>
                    <option value="Green">Green</option>
                    <option value="Blue">Blue</option>
                </select>
                <br>
                <br>
                <B>Country:</B>
                <select name="country" size="1">
                    <option value="India">India</option>
                    <option value="Srilanka">Srilanka</option>
                    <option value="Chinae">China</option>
                </select>
                <br>
                <br>
                <input type=submit value="Submit">
        </form>
        </center>
    </body>
    </html> 
The servlet is
public class TwoParServlet extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
        String color = request.getParameter("color");
        String country = request.getParameter("country");
        response.setContentType("text/html");
        PrintWriter pw = response.getWriter();
        pw.println("<p>The selected color is:  ");
        pw.println(color);
        pw.println("<p>The selected country is:  ");
        pw.println(country);
        Enumeration names;
        names = request.getAttributeNames();
        pw.println("<p> First value received = " + names.nextElement());
        //pw.println("<p> First value received = " + names.nextElement());
        pw.close();
}
}
When I run the project am getting this error
Exception report message description The server encountered an internal error that prevented it from fulfilling this request.
exception
java.util.NoSuchElementException
java.util.HashMap$HashIterator.nextEntry(HashMap.java:929)
java.util.HashMap$KeyIterator.next(HashMap.java:960)
java.util.Collections$2.nextElement(Collections.java:3665)
p1.TwoParServlet.doGet(TwoParServlet.java:36)
javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51)
What might have gone wrong?
 
     
     
     
    