This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes Servlets and the fly likes Get Cell Values from HTML Table Using Servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Servlets
Reply Bookmark "Get Cell Values from HTML Table Using Servlet" Watch "Get Cell Values from HTML Table Using Servlet" New topic
Author

Get Cell Values from HTML Table Using Servlet

Ananth sunraj
Greenhorn

Joined: Sep 05, 2008
Posts: 12
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
Marshal

Joined: Mar 22, 2005
Posts: 35241
    
    7
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.


Android appsImageJ pluginsJava web charts
Ananth sunraj
Greenhorn

Joined: Sep 05, 2008
Posts: 12
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
Marshal

Joined: Mar 22, 2005
Posts: 35241
    
    7
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

Joined: Sep 05, 2008
Posts: 12
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

Joined: Jan 10, 2002
Posts: 56191
    
  13

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.


[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
Rahul Deshmukh
Greenhorn

Joined: Sep 06, 2008
Posts: 1
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

Joined: Jan 10, 2002
Posts: 56191
    
  13

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

Joined: Aug 11, 2007
Posts: 4422
    
    2

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://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Get Cell Values from HTML Table Using Servlet
 
Similar Threads
JTable+JCheckBox
problems displaying values in JTable
Urgent! jtable get value when cell is edited
how to update JTable values
Geting a Cell Content Value