Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to store HTML table values in DB

 
Raveesh Lawrance
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am new to struts. i am having one jsp file that contains datas with table. i want to collect all the table data values and stroe it in DB while clicking the submit button. how to do that... please help me.... Thanks in advance....
 
Sagar Rohankar
Ranch Hand
Posts: 2907
1
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is a basic things which could be done, if you have some experience in JSP/Servlets[This is prerequisite for Struts]

Ok, still this will be a good start !
 
Raveesh Lawrance
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok Thanks. Please help me how to store table values in DB
 
Sagar Rohankar
Ranch Hand
Posts: 2907
1
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Raveesh Lawrance wrote:ok Thanks. Please help me how to store table values in DB

I provided a link in my first reply to your first thread, Still I'm giving some more,
http://wiki.apache.org/struts/StrutsArticles
You have to learn this basics first, then If you were stuck between implementing, then you post here about where you stuck, What you did and what you expect ??
 
Raveesh Lawrance
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
jsp file - That contains table with 3 Row values and one submit button, while clicking the submit button all the table values should pass to java class file using server.






 
Sagar Rohankar
Ranch Hand
Posts: 2907
1
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Raveesh Lawrance wrote:jsp file - That contains table with 3 Row values and one submit button, while clicking the submit button all the table values should pass to java class file using server.

Ok, here is what you required,

1. ActionForm(bean, with getter/setter property) : This holds you FORM/Table values
2. ActionClass (servlet): Called upon when you click "Submit", Process your requests
3. JSP page, (View), <table></table>
4. A java class with DB connection object and method which inserts data into DB

Can you get this ??
 
Raveesh Lawrance
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
no. i just created all the files(Action, Class, Form and DB) I need the procedure how to pass the all table values into javaclass file while clicking submit button.
 
Sagar Rohankar
Ranch Hand
Posts: 2907
1
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok,
struts-config.xml

JSP


Action, MyAction.java

HTH
 
Raveesh Lawrance
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry i think you are misunderstood wht im trying to say.
Here is my coding.
<table>
<tr align="center">
<td align="center" style="width:300px;"> Flag Name_1 </td>
<td align="center" style="width:300px;"> 1 </td>
<td align="center" style="width:300px;"> Flag Notes_1 </td>

</tr>

<tr align="center">
<td align="center" style="width:300px;"> Flag Name_2 </td>
<td align="center" style="width:300px;"> 2 </td>
<td align="center" style="width:300px;"> Flag Notes_2 </td>

</tr>
</table>
<input style="background-color:010280; color:white" type="Submit" name="commit" value="Commit">

I want to pass all these table datas into java class while clicking the commit button

 
Sagar Rohankar
Ranch Hand
Posts: 2907
1
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use Code Tags

A point to remember, you must declare 'bean', like

And its mapping in correct action tag
 
Dhruva Mistry
Ranch Hand
Posts: 67
Eclipse IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Raveesh Lawrance wrote:Sorry i think you are misunderstood wht im trying to say.
Here is my coding.
<table>
<tr align="center">
<td align="center" style="width:300px;"> Flag Name_1 </td>
<td align="center" style="width:300px;"> 1 </td>
<td align="center" style="width:300px;"> Flag Notes_1 </td>

</tr>

<tr align="center">
<td align="center" style="width:300px;"> Flag Name_2 </td>
<td align="center" style="width:300px;"> 2 </td>
<td align="center" style="width:300px;"> Flag Notes_2 </td>

</tr>
</table>
<input style="background-color:010280; color:white" type="Submit" name="commit" value="Commit">

I want to pass all these table datas into java class while clicking the commit button




you can put javascript for onSubmit event besides the <form> just call a method to take the value of needed fields and
in java class you can set the values
 
Sagar Rohankar
Ranch Hand
Posts: 2907
1
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
dhruva mistry wrote:
you can put javascript for onSubmit event besides the <form> just call a method to take the value of needed fields and
in java class you can set the values


How?
 
Dhruva Mistry
Ranch Hand
Posts: 67
Eclipse IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sagar Rohankar wrote:
dhruva mistry wrote:
you can put javascript for onSubmit event besides the &amp;lt;form&amp;gt; just call a method to take the value of needed fields and
in java class you can set the values


How?



likewise:



with the class:
class MyBean extends ActionForm
{
String flagNameOne;
String flagNameValue;
.
.
// other properties

// getter/setter here
}


 
Sagar Rohankar
Ranch Hand
Posts: 2907
1
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
dhruva mistry wrote:



Have you read from start, what are we trying to do here, simple GET and INSERT data..
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic