Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Java-Interview-Questions Radio button with values from a String ArrayList in JSP?

Have Programming Question? Ask it here!
 
 
 


Sarbu Diana
Radio button with values from a String ArrayList in JSP?
0 Answer(s)      a year and 11 months ago
Posted in : Java Interview Questions


Radio button values in JSP

ArrayList<String> cs = CourseAssignments.getInstance().getStudentCoursesByName(sname); 
                 %>
                  <table border="1" cellspacing="1" cellpadding="8" bgcolor= #EBDDE2> 
                <%
                Iterator<String> i = cs.iterator();
                while(i.hasNext()){
                %>
                <tr>
                  <td><%= i.next() %><input type= "radio" name= "courses" value="<%= i.next() %>"/></td>
                </tr>
                <%}%>
            </table>
              <center><input type= "submit" value= "Submit"></center>
              </form>
                 <%}

In ArrayList cs I have all the courses that a student has. In a table I show these courses and it works if I don't use RADIO input. I want to display a radio button near each course, then user selects one and I will display the marks for that course.

I get: "org.apache.jasper.JasperException: An exception occurred processing JSP page /ComplexSearch/Seek.jsp at line 61

58:                 while(i.hasNext()){
59:                 %>
60:                 <tr>
61:                   <td><%= i.next() %><input type= "radio" name= "courses" value="<%= i.next() %>"/></td>
62:                 </tr>
63:                 <%}%>
64:             </table>
java.util.NoSuchElementException
    java.util.ArrayList$Itr.next(Unknown Source)
    org.apache.jsp.ComplexSearch.Seek_jsp._jspService(Seek_jsp.java:136)
    org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
"

Advertisement
View Answers

Related Tutorials/Questions & Answers:
Advertisements
 

 

 

DMCA.com