aspose file tools*
The moose likes Servlets and the fly likes Import whole table. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Import whole table." Watch "Import whole table." New topic
Author

Import whole table.

Noopur Kore
Ranch Hand

Joined: Aug 18, 2012
Posts: 77

I want to make a servlet where I insert the whole table that I made on HTML page in my Oracle db.
I can insert elements individually, as all HTML tags have 'name' attribute. What should I do if I want to insert the whole table into the Oracle db I made.

Please give some idea.
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 31052
    
162

What do you mean by "whole table"? The HTML making up the table on the page? Multiple fields? Can you give an example?


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Noopur Kore
Ranch Hand

Joined: Aug 18, 2012
Posts: 77

this is how the table works..




Now when am done inserting many such rows. I want to submit all data in my oracle db.

P.S : fname is my global variable and I have taken its value in another function.
William P O'Sullivan
Ranch Hand

Joined: Mar 28, 2012
Posts: 859

That's JavaScript.

So you want to then POST the changes to a servlet for insertion to Oracle?

WP
Noopur Kore
Ranch Hand

Joined: Aug 18, 2012
Posts: 77

Yes.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61755
    
  67

What's the exact problem? If all the element are being POSTed to a servlet, simply retrieve the values, and send them to a model class that inserts the values into the DB.

Which part are you having problems with?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Noopur Kore
Ranch Hand

Joined: Aug 18, 2012
Posts: 77

Actually the problem is, all the elements are just getting printed in my HTML file. There are no means to identify these elements individually or together for me to POST them in servlet.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61755
    
  67

Anything that you want to be posted must be a form element -- usually an <input> element of some kind (or textarea, select, et al).

Alternatively, you could write some JavaScript to grab simple text from table cells and encode that properly for POSTing via hidden inputs or via Ajax. But I'd only head down that road if the much easier input element approach is impossible for some reason.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61755
    
  67

P.S. making the input elements readonly and styling them with CSS can make them look exactly like simple text and not editable, so appearance concerns are no barrier to using input elements.
Noopur Kore
Ranch Hand

Joined: Aug 18, 2012
Posts: 77

Actually I'm unable to make the table by input as I want to add elements to it through Javascript.
Any idea, how its done?
Or how to POST a table to servlet to add it to oracle db.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61755
    
  67

Noopur Kore wrote:Actually I'm unable to make the table by input as I want to add elements to it through Javascript.

Using JavaScript in no way prevents you from using input elements. Why do you think so?

Or how to POST a table to servlet to add it to oracle db.

Again, you can't post a table. Period. End. Full stop.

You post form elements. Keeping asking for the impossible isn't going to get you anywhere.
Noopur Kore
Ranch Hand

Joined: Aug 18, 2012
Posts: 77

Ok. I got it.

Back to the former one.

I posted the javascript.
Here's the HTML code for my table which contains only headings.

<table id="table1">
<tr>
<th width="10%">Serial number</th>
<th width="20%">Field Name</th>
<th width="30%">Text</th>
<th width="10%">Font Name</th>
<th width="10%">Font Size</th>
<th width="10%">X Co-ordinate</th>
<th width="10%">Y Co-ordinate</th>
</tr>
</table>

The elements which i call to add a row to the table are coming from another <div> and this table is another <div>.
Can anyone help to separate these elements once I have added them to table??
William P O'Sullivan
Ranch Hand

Joined: Mar 28, 2012
Posts: 859

Ok.

Looking at your "code", you may have to build a custom POST in JavaScript.

WP
Noopur Kore
Ranch Hand

Joined: Aug 18, 2012
Posts: 77

Any ideas or hints for how to go about that?
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Import whole table.