File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Get Cell Values from HTML Table Using Servlet

 
Ananth sunraj
Greenhorn
Posts: 12
  • 0
  • Mark post as helpful
  • send pies
  • 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
 
Ulf Dittmer
Rancher
Pie
Posts: 42966
73
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • 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
Pie
Posts: 42966
73
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • 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.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64186
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • 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.
 
Rahul Deshmukh
Greenhorn
Posts: 1
  • 0
  • Mark post as helpful
  • send pies
  • 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
Author and ninkuma
Marshal
Pie
Posts: 64186
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • 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.
 
Pat Farrell
Rancher
Posts: 4660
5
Linux Mac OS X VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • 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?
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic