• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to retrieve “Grouped” items from HTML form using Servlet?

 
Ranch Hand
Posts: 507
Netbeans IDE Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
First of all, I have posted this question in here but not satisfied with the answers.

I am having an issue with retrieving "grouped" data from HTML form to servlet. I will describe the scenario below.

In companies, they record the salary of the employees once a month.When they record it, they do not do it by visiting each an every employees personal "profile" (or whatever according to the system). Instead what they do is apply the salaries of all of them in one page.

To do the above thing they prefer excel like tabular sheets.

Now, I have a html form, where the form content is a table. One row is dedicated to a one employee.

Below is my form.




As you can see, I have wrapped every row with a `<tbody>`. The `value` attribute of the `<tbody>` will contain the employee id.

Once the form is submitted, the below servlet will capture it.




What I was trying is get the `value` attribute of `<tbody>` (so I can identify the id of the employee) and get the data inside that `<tbody>`. However this didn't work, because I ended up with `NullpointerException` because it failed to read the `<tbody>` value.

So, how can I pass the data from table to servlet where it can clearly understand that one row is representing data belong to a one employee? If this is not the way to do it, I am also open for other methods.
 
Bartender
Posts: 1810
28
jQuery Netbeans IDE Eclipse IDE Firefox Browser MySQL Database Chrome Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Perhaps you should explain why you are not satisfied with the answers you got on SO. The first response explains it pretty clearly. You need unique name values for each field and appending an employee id as the table is built seems like the best way to me.

And incidentally, having multiple tbody elements in one table is invalid html and will only cause you problems.
 
Greenhorn
Posts: 8
1
Netbeans IDE Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

J. Kevin Robbins wrote:And incidentally, having multiple tbody elements in one table is invalid html and will only cause you problems.



This appears to be incorrect. According to the specs for both HTML 5 and HTML 4, a table may contain multiple tbody elements.
 
Sheriff
Posts: 67747
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Rgeardless, they are completely unnecessary and overcomplicate the markup needlessly, and the name attribute usage upon them is invalid.
 
J. Kevin Robbins
Bartender
Posts: 1810
28
jQuery Netbeans IDE Eclipse IDE Firefox Browser MySQL Database Chrome Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Christian Taylor wrote:

J. Kevin Robbins wrote:And incidentally, having multiple tbody elements in one table is invalid html and will only cause you problems.



This appears to be incorrect. According to the specs for both HTML 5 and HTML 4, a table may contain multiple tbody elements.



That's interesting. I stand corrected, but now I'm wondering why you would want to do that.
 
Christian Taylor
Greenhorn
Posts: 8
1
Netbeans IDE Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

J. Kevin Robbins wrote:

Christian Taylor wrote:

J. Kevin Robbins wrote:And incidentally, having multiple tbody elements in one table is invalid html and will only cause you problems.



This appears to be incorrect. According to the specs for both HTML 5 and HTML 4, a table may contain multiple tbody elements.



That's interesting. I stand corrected, but now I'm wondering why you would want to do that.



Grouping of rows could be useful in some scenarios, for styling purposes or possibly manipulating the DOM to sort or move groups of rows more easily than each related row individually. Bear is certainly correct that they don't help anything in this situation and they are being used in an invalid way, so I'll leave it at that and not take this any further off-topic from Yohan's original question.
 
Yohan Weerasinghe
Ranch Hand
Posts: 507
Netbeans IDE Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The answer in SO really worked. Thanks for the help guys.
 
The happiness of your life depends upon the quality of your thoughts -Marcus Aurelius ... think about this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic