Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8317933
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T21:46:42+00:00 2026-06-08T21:46:42+00:00

my form has several checkboxes on it (around 15) and the issue im having

  • 0

my form has several checkboxes on it (around 15) and the issue im having is that the names of the check boxes only appear in the enumeration if they are checked but i want all of them to be returned so that when i print the data it will have the name of the checkbox and say “checked” or “unchecked”. i had thought of one way that i could just manually set the flag to see what is present and what isnt, but that doesnt seem remotely efficient.

public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
 {

        try
        {
            FileWriter writer = new FileWriter("OrderFormData.csv");
            writer.append("FieldName");
            writer.append(',');
            writer.append("Value");
            writer.append('\n');
            @SuppressWarnings("unchecked")
            Enumeration <String> paramNames = request.getParameterNames();
            while(paramNames.hasMoreElements()) 
            {
                String paramName = (String)paramNames.nextElement();
                writer.append(paramName);
                writer.append(',');
                String[] paramValues = request.getParameterValues(paramName);
                if (paramValues.length == 1)
                {
                    String paramValue = paramValues[0];
                    if (paramValue.length() == 0)
                    {
                        writer.append("No Value");
                        writer.append('\n');
                    }
                    else
                    {
                        writer.append(paramValue);
                        writer.append('\n');
                    }
                }
                else
                {
                    for(int i = 0; i<paramValues.length; i++)
                    {
                        writer.append(paramValues[i]);
                        writer.append(',');
                    }
                    writer.append('\n');
                }


            }
            writer.flush();
            writer.close();
        }
        catch(IOException e)
        {
             e.printStackTrace();
        }

    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T21:46:45+00:00Added an answer on June 8, 2026 at 9:46 pm

    You should think in a workaround because as @Alex told you, unchecked checkboxes are not part of the request.

    This is just an idea, but for example:

    <input type="hidden" name="checkboxNamesList" value="nameCheckbox1" />
    <input type="hidden" name="checkboxNamesList" value="nameCheckbox2" />
    <input type="hidden" name="checkboxNamesList" value="nameCheckbox3" />
    <input type="hidden" name="checkboxNamesList" value="nameCheckbox4" />
    

    Then, you can get checkboxNamesList from the request (it will be a String[]) so you will have all the checkboxes params names. If you get a parameter for one of the checkboxes name and value is null, it means that checkboxe was not checked.

    Edited: clarification

    Well, as unchecked checkboxes are not present in the request you don’t know whose checkboxes in the JSP were not checked but you need to know it in order to write in your data file something like checkbox_name1=unchecked.

    So, how to do that? First, you need to know what checkboxes (uncheck or not) were present in the request. For that, you can use the code below and get name of all checkboxes present in the JSP:

    String[] checkboxNamesList= request.getParameterValues("checkboxNamesList");
    

    Then, let look for unchecked checboxes:

    for (int i = 0; i < checkboxNamesList.length; i++) {
    
        String myCheckBoxValue = request.getParameterValues(checkboxNamesList[i]);
    
        // if null, it means checkbox is not in request, so unchecked 
        if (myCheckBoxValue == null)
            writer.append(checkboxNamesList[i] + "=unchecked");
    
        // if is there, it means checkbox checked
        else
            writer.append(checkboxNamesList[i] + "=checked");
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i currently have a form that has several check boxes, once all the boxes
I have a big form with several checkboxes, having names chkbx0..chkbxN for them (N
I have a page that has several ajax submission forms. Each form has a
I have a winforms app and the main (and only) form has several buttons.
I'm working on a long form that has several radio button groups. At the
the user has the option of dragging several pictureboxes around the form. when he
I have a form that has several controls: ProgressBar at the top of the
I have a form with a table that has two input boxes, a select
I have one form that has several elements and two submit buttons, one is
I have a Project in which there is a form that has several objects

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.