Solved

Servlets & Checkboxes

Posted on 2000-05-10
1
162 Views
Last Modified: 2013-11-24
I have a servlet that creates dynamic html with rows in a table, each row has a check box so the row can be selected.  The user can select any or all of the check boxed rows.

How do I pass and then find out which rows where checked in the next servlet that is called?

Thank you in advance.
0
Comment
Question by:suzuki
1 Comment
 

Accepted Solution

by:
Rich6176 earned 100 total points
ID: 2797420
  When the checkbox is created by the original servlet make sure the name and values are unique for each element. Say for instance the first checkbox of the first row could have it's name set to A1, next A2, A3, etc..... When the form is then submitted only the names and values of the checked checkboxes will be returned then you can sort the name and value of the parameters sent to construct the next .html file.
Try this code if your having trouble with parameters

private void getParams(HttpServletRequest req)
{
      Enumeration enum = req.getParameterNames();
      String value;
      String name;
      
      while (enum.hasMoreElements());
      {
            name = (String)enum.nextElement();
            value = req.getParameter(name);
            System.out.println(name + " = " + value);

            if (name.equals("A1"))
                this.firstCheckboxClicked();
      }
}
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now