• 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

Get Cell Values from HTML Table Using Servlet

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I have created a dynamic table using Javascript and JSP.
I need to get the values of the all cells, and store it in database.
how to get the cell values using Servlets. if any body got an idea suggest me with code.

thanks in advance.
Subscribe
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hello "subscribeid subscribeid"-

Welcome to JavaRanch.

On your way in you may have missed that we have a policy on screen names here at JavaRanch. Basically, it must consist of a first name, a space, and a last name, and not be obviously fictitious. Since yours does not conform with it, please take a moment to change it, which you can do right here.

As to your question, the usual way to store values from an HTML page is to submit them to the server using an HTML form. Can you arrange for the elements to be part of a form?

An alternative would be to collect all the data values as GET parameters in an URL, and to send that to the server via JavaScript. Using GET for a save operation is generally frowned upon, though. Using a POST from within a form would be cleaner.
 
Ananth sunraj
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I need to get the cell values of the HTML Table which is genereted dynamically. Is there is any ideas let me know.
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for changing the display name. Unfortunately it doesn't yet meet the requirements, as I'm assuming that "subscribeid" is not your last name. Please fix this; accounts without valid display names are generally closed quickly.

What does "is generated dynamically" mean? By JSP? By JavaScript? By both? How exactly? Is there anything that would stop you from embedding a form containing the values -possibly as hidden elements- in the page?
 
Ananth sunraj
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
my table is generated using javascript and JSP. I need to get cell values of every rows and every columns.
thanks for your immediate response.
 
Sheriff
Posts: 67746
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
Values in table cells are not submitted as part of a request. As Ulf suggested, you'll either need to copy the data into hidden elements that will be submitted, or to display the values in text fields to begin with.
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

As Ulf suggested, you can set it as a hidden parameter.

Or you can even create a collection on your jsp with the values of the elements. Then set the collection object in your request as a parameter/attribute. Iterate over it in your servlet and save to database.
 
Bear Bibeault
Sheriff
Posts: 67746
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

Originally posted by Rahul Deshmukh:
you can even create a collection on your jsp with the values of the elements. Then set the collection object in your request as a parameter/attribute. Iterate over it in your servlet and save to database.


No, that won't work. Any scoped attribute set on the request will go out of scope as soon as the response is sent to the client.
 
Rancher
Posts: 4803
7
Mac OS X VI Editor Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm confused. Of the cell values are in a table in HTML that your server generated in a Servlet, why don't you already know the values? Its your code generating the values.

Why do you need to pull them from the generated HTML?
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic