File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes Get Cell Values from HTML Table Using Servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
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: 42929
    
  68
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

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: 42929
    
  68
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: 61766
    
  67

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.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by 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: 61766
    
  67

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: 4659
    
    5

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
 
subject: Get Cell Values from HTML Table Using Servlet