checking which check boxes are selected using JAVA ( a jsp)

后端 未结 4 1451
灰色年华
灰色年华 2021-01-02 13:09

I am trying to create a servlet that displays a simple form with checkboxes , when the user selects the number of checkboxes he wants and clicks on a \"confirm\" the POST re

4条回答
  •  长情又很酷
    2021-01-02 13:47

    <%@ page language="java"%>
    
        
            
            JSP Multiple Checkbox
        
        
            

    Select your favorite Fruits

    Mango

    Apple

    Grapes

    Papaya

    Lychee

    Pineapple

    <%String fruits[]= request.getParameterValues("fruit"); if(fruits != null){%>

    I likes fruit/s mostly

      <%for(int i=0; i
    • <%=fruits[i]%>
    • <%}%>
    <%}%>

    Run this sample jsp on your web container to get some basic idea on how it works. You need to move the display logic on this page that gets request parameter into your servlet code on form submission. This example can be found from here. Hope this would help.

提交回复
热议问题