0

I am trying to implement a simple dynamic dropdown menu in JSP.I am using MONGODB.Here is my code.But I am getting

<select name="village" id="village">
                <option value="0">Select Village</option>
                <%

                BasicDBObject adminQuery = new BasicDBObject();

        DBCursor cursor = villages.find(adminQuery);
            while(cursor.hasNext()){

               %>
               <option value="<%= cursor.next().get("Village").toString()%>"> 
                              <%= cursor.next().get("Village").toString()%>
                  </option>
                      <% } %>
              </select>

But I am getting following exception

org.apache.jasper.JasperException: An exception occurred processing JSP page /home.jsp at line 116

113:                 
114:               %>
115:               <option value="<%= cursor.next().get("Village").toString()%>"> 
116:                              <%= cursor.next().get("Village").toString()%>
117:                  </option>
118:                      <% } %>
119:              </select>

I don't know where is the problem.Please Help me

ding dang
  • 19
  • 1
  • 4

1 Answers1

0

Use single quotes instead of double quotes. Try this

<option value="<%= cursor.next().get('Village').toString() %>" ><%= cursor.next().get('Village').toString() %></option>
faizi
  • 1,265
  • 2
  • 12
  • 28