• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

crating a table using JSP

 
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

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,
Sriram.V
 
abhishek rathur
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thank you Sri for replying
I am using Mysql,i have done my connectivity using JDBC and its working,what i need is to select one of the values from the table and pass that value to another form.
 
sri ramvaithiyanathan
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Okay i am giving the sample code and change it accordingly.


Mostly bean is used to set the value and you can get the bean value in action file.
Let me know if you have any more query.

Regards,
Sriram.V
 
Ranch Hand
Posts: 112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

1.How to select a data from the table.


Can follow the below approach.

2.How to send the selected data to other form.



Just my thoughts!!
 
Ranch Hand
Posts: 3389
Mac MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.


  • Hope this helps!!
     
    Don't get me started about those stupid light bulbs.
    reply
      Bookmark Topic Watch Topic
    • New Topic