I am creating a web application in which there is a table which gets values from database, what i need is to select one of the table value and pass it to another form.
things i am looking for
1.How to select a data from the table.
2.How to send the selected data to other form.
which database you are using oracle or mysql.
According to that you have to create one java file to establish connection with database.
You have to know some basic knowledge in jdbc.
Basic example is here just click this Link Regards,
Typically this should involve the following steps.
1. In your Java code, you fetch the data from table using JDBC. I hope you are good at it.
2. Bind the fetched values (typically in a JavaBean which is used as a POJO (Plain Old Java Object)) to any of the request or session scopes depends on your need. Request scope is for a lesser life span as the values will stay only for this request's lifecycle. Session scope is bigger as the values continue stay for the entire session.
3. Redirect the control from your Java code (typically a Servlet which will act as a controller) to the required JSP page
4. Using EL (Expression Language) and custom Tag (C tags) you can retrieve the bound value with the key and iterate the value to display them in a table.
Next thing comes how to select the value and send it to other form.
Here it just separates from your previous flow. After displaying the values in the JSP pages, you think it is a fresh request.
Along with each row you add a control (say a check box or a radio button depends on your need). The user has to click on the control (say a radio button of his choice). While you are displaying the table with a radio button, you have to map or bind the radio button with the unique id (say database table's primary key for example) for each radio button.
On clicking that radio button and a submit button the request will have to submitted to a different JSP page. The selected radio button will have the primary key as its value, which you can retrieve in the forwarded JSP page using the Expression Language as follows.
with the radioButton Id you can get the data here in this JSP page. But how will you get the full details of the row with the passed Id?
There are two choices.
1. You can retrieve the complete values from DB with the radioButton Id as a primary key
2. You can store the values in a HashMap in your application (they call it as a cache) by having the primary key as a Key and the appropriate POJO (Java Bean) as a value into the hashmap. Whenever you want the full details, pass on the radioButtonId (as a key) to hashmap and retrieve the POJO. Then you will get the full details in the POJO.