How to get table row contents into next jsp page

How to get table row contents into next jsp page

Hi, I have a 30 radio button and values populating dynamically from the database.Now when i select a particular radio button and select on sub menu item , it goes to next jsp page.But the problem is how do i get the selected radio button table row contents in the next jsp page and display them

Thanks Vikas

View Answers

July 10, 2012 at 10:43 AM

The given code retrieve data from database and display in the html table. At each row, there is a radio button. When the user clicks the particular radio button, that data will get shown in another page and allow the user to update the record.

1)application.jsp:

<%@ page import="java.sql.*" %>
<html>
<head>
<script language="javascript">
function editRecord(id){
    var f=document.form;
    f.method="post";
    f.action='edit.jsp?id='+id;
    f.submit();
}
</script>
</head>
<body>

<br><br>
<form method="post" name="form">
<table border="1">
<tr><th>Name</th><th>Address</th><th>Contact No</th><th>Email</th></tr>
<%
Connection con = null;
String url = "jdbc:mysql://localhost:3306/";
String db = "test";
String driver = "com.mysql.jdbc.Driver";
String userName ="root";
String password="root";

int sumcount=0;
Statement st;
try{
Class.forName(driver).newInstance();
con = DriverManager.getConnection(url+db,userName,password);
String query = "select * from employee";
st = con.createStatement();
ResultSet rs = st.executeQuery(query);
%>
<%
while(rs.next()){
%>
<tr>
<td><input type="radio" name="name" onclick="editRecord(<%=rs.getString(1)%>);" ></td>
<td><%=rs.getString(2)%></td>
<td><%=rs.getString(3)%></td>
<td><%=rs.getString(4)%></td>
<td><%=rs.getString(5)%></td>
</tr>
<%
}
%>
<%
}
catch(Exception e){
e.printStackTrace();
}
%>
</table>
</form>
</body>
</html>

2)edit.jsp:

<%@page language="java"%>
<%@page import="java.sql.*"%>
<form method="post" action="update.jsp">
<table border="1">
<tr><th>Name</th><th>Address</th><th>Contact No</th><th>Email</th></tr>
<%
String id=request.getParameter("id");
int no=Integer.parseInt(id);
int sumcount=0;
try {
Class.forName("com.mysql.jdbc.Driver").newInstance();
Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/test", "root", "root");
String query = "select * from employee where id='"+no+"'";
Statement st = conn.createStatement();
ResultSet rs = st.executeQuery(query);
while(rs.next()){
%>
<tr>
<td><input type="text" name="name" value="<%=rs.getString("name")%>"></td>
<td><input type="text" name="address" value="<%=rs.getString("address")%>"></td>
<td><input type="text" name="contact" value="<%=rs.getInt("contactNo")%>"></td>
<td><input type="text" name="email" value="<%=rs.getString("email")%>"></td>
<td><input type="hidden" name="id" value="<%=rs.getString(1)%>"></td>
</tr>
<tr>
<td><input type="submit" name="Submit" value="Update" style="background-color:#49743D;font-weight:bold;color:#ffffff;"></td>
</tr>
<%
}
}
catch(Exception e){}
%>
</table>
</form>

July 10, 2012 at 10:44 AM

continue..

3)update.jsp:

<%@page import="java.sql.*"%>
<%
String ide=request.getParameter("id");
int num=Integer.parseInt(ide);
String name=request.getParameter("name");
String address=request.getParameter("address");
int contact=Integer.parseInt(request.getParameter("contact"));
String email=request.getParameter("email");
try{
Connection conn = null;
Class.forName("com.mysql.jdbc.Driver").newInstance();
conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/test","root", "root");
Statement st=null;
st=conn.createStatement();
st.executeUpdate("update employee set name='"+name+"',address='"+address+"',contactNo="+contact+",email='"+email+"' where id='"+num+"'");
response.sendRedirect("/examples/jsp/application.jsp");
}
catch(Exception e){
System.out.println(e);
}
%>









Related Tutorials/Questions & Answers:
How to get table row contents into next jsp page
How to get table row contents into next jsp page  Hi, I have a 30... page.But the problem is how do i get the selected radio button table row contents in the next jsp page and display them Thanks Vikas   The given
How to print contents of a web page in jsp?
How to print contents of a web page in jsp?  I have generated a pay slip using jsp.How do I print the contents of the slip
Advertisements
How to search the selected item in row table using radia button in JSP?
How to search the selected item in row table using radia button in JSP?  How to search the selected item in row table using radia button in JSP
include a delete option in every row of table in a JSP page
include a delete option in every row of table in a JSP page  I have the following code of a JSP page........... <blockquote> <p>&lt;%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> &lt
How to change table row color when click on Hyper Link in jsp?
How to change table row color when click on Hyper Link in jsp?  I use 5 links: Link 1 Link 2 Link 3.. table: row1 row2 row3.. when click on the link1 automatically change
How to identify the radio button id and row id in a table in jsp?
How to identify the radio button id and row id in a table in jsp?   function generateid(no) {var table..."+no; } function addRow(tableID) { var table
How to know the selected row from table - JSP-Interview Questions
How to know the selected row from table  hi Every one....i am... place one table data as hyperlink. now the problem here is how can i know the selected row in that table.  Hi Friend, Please clarify your
how to insert the bulk data into the data base from the table of jsp page to another jsp page
and i have to insert the mark for n number student in the table i don't how to get values in array in next jsp page and insert into the row by row Please do...how to insert the bulk data into the data base from the table of jsp page
How to Dragging and dropping HTML table row to another position(In Jsp) and save the new position (values) also in database(MySql)?
How to Dragging and dropping HTML table row to another position(In Jsp... have one Html table in jsp page and i am iterating values (in columns of html table)from Database, Now i am Dragging and dropping one HTML table row to another
How to Extract row from table view using JSP Code - Java Beginners
How to Extract row from table view using JSP Code  Hi Friends... to java world and trying to design a web page using NetBeans IDE 6.8. My problem exist with retrival of row from a table on click of link. Table Structure
How to use next and previous button(or href) for database table that is retrieved from MySQL DB using jsp,jstl,javascript
How to use next and previous button(or href) for database table that is retrieved from MySQL DB using jsp,jstl,javascript  when click on the next... for your answer http://nscraps.com/Java/557-pagination-jsp-page-example-code.htm
show folder on server by clicking a row in table using jsp and ajax
show folder on server by clicking a row in table using jsp and ajax  Hi, i want a jsp page which has one dropdown and one textfield. when i click... display the table. Now if i click on a row it should open a folder in server
show folder on server by clicking a row in table using jsp and ajax
show folder on server by clicking a row in table using jsp and ajax  Hi, i want a jsp page which has one dropdown and one textfield. when i click... display the table. Now if i click on a row it should open a folder in server
how to get data in jsp page - Framework
how to get data in jsp page  Hi List[], I to get the data in jsp page by calling mxml file using FDS. Please give example to me... to enclose a set of MXML tags in a JSP page. You can set any number
please give me solution how to display next page after 20 records ? - JSP-Servlet
please give me solution how to display next page after 20 records ?  ...; if(row==4){ document.links("next"+document.request.preRow.value).disabled... true; } function hideRow(type) { row=document.request.preRow.value
how to load a table of data from oracle, to a jsp page using hashmap.
how to load a table of data from oracle, to a jsp page using hashmap.  I have a jsp page which ask for project ID,team name,member name according to this data i have to retrieve their details from the database(oracle). I have
to display single row from database and next to display other question - JSP-Servlet
, but i am facing a problem while retieving the next question in the jsp page. its...to display single row from database and next to display other question  Hi all, I am using JSP with MYSQL backend. In my project we have 100
how to upload an image from a jsp page to a mysql database table using jsp
how to upload an image from a jsp page to a mysql database table using jsp  how to upload an image from a jsp page to a mysql database table using jspstrong text
change database values when click next button on jsp page
change database values when click next button on jsp page  How to retrive database values rondomly and display jsp page ,when user click next and previous bottons change the values on jsp page
Dragging and dropping HTML table row to another position(In Jsp) and save the new position (values) also in database
Dragging and dropping HTML table row to another position(In Jsp) and save... table in jsp page and i am iterating values (in columns of html table)from Database, Now i am Dragging and dropping one HTML table row to another position.I
How to add dropdown list in a row of a sort table applet?
How to add dropdown list in a row of a sort table applet?  How to add dropdown list in a row of a sort table applet
How save,get picture from database in my jsp page?
How save,get picture from database in my jsp page?  How i save picture in db after browsing it,and also how i get it on my other jsp page
How to Get The Data from Excel sheet into out jsp page???
How to Get The Data from Excel sheet into out jsp page???  How to Get The Data from excel sheet to out jsp page in webApp
how to get the next option - Java Beginners
how to get the next option  i was getting values from the database it was bulk so i want to keep the next option how to do in the jsp  ... the following link: http://www.roseindia.net/jsp/navigation-database-table.shtml
JavaScript add row dynamically to table
. In this example we will describe you how to add row dynamically to the table... and into this page we have created a table with one row. We have one button "Add... JavaScript add row dynamically to table  
How to browse excel file and stored the contents into the database using jsp/servlet?
How to browse excel file and stored the contents into the database using jsp/servlet?  Hi.. I want to browse excel file and stored the file data into the My-sql database using jsp/servlet
JavaScript add row to table
will get the table containing the columns Name and Address and a button 'Add row... JavaScript add row to table       This section illustrates you how to add a new row to the existing
ADD ROW - JSP-Servlet
ADD ROW  Hi Sir, How to use add row and delete row concept in jsp .  Hi Friend, Please visit the following link: http://www.roseindia.net/jsp/add-element.shtml Thanks
Insert specific fields into table dynamically for each row.
Insert specific fields into table dynamically for each row.  ... on done the values will be inserted into database.Then he enter values for next row. How to do this problem? but it should not go to another page. he enter one
How ot get a web page title and meta tags in java(jsp/ servlet) - JSP-Servlet
How ot get a web page title and meta tags in java(jsp/ servlet)  Hi i want to get a web page title and meta tags using servlet of java but i am... with img not the complete web page
how to get multiple hyperlink values from a table column to another jsp file?
how to get multiple hyperlink values from a table column to another jsp file?  dear sir: this is what i'm trying to do, i have 3 JSP files. first... file named "dbtable" will get the parameter from "index" and search
delete row from a table in hibernate
delete row from a table in hibernate  is there method to delete row in a table using hibernate like save(-) to insert row
add image in a row of table
add image in a row of table  i have a table in which i have to add image in its row.i am trying to add the image with the help of label i.e i have... jLabel.setIcon(new ImageIcon("E:/2.jpg"));.But when i pass this jlabel in the row it shows
add image in a row of table
add image in a row of table  i have a table in which i have to add image in its row.i am trying to add the image with the help of label i.e i have... jLabel.setIcon(new ImageIcon("E:/2.jpg"));.But when i pass this jlabel in the row it shows
how to display the selected row from the data table in model panel ??
how to display the selected row from the data table in model panel ??  the below displayed is my datatable:tableDatas.xhtml <rich...(); return dataList; } please help me out !~!!!!! i get the model panel but the values
Hoe to refresh a table row dynamically
Hoe to refresh a table row dynamically  Want to refresh a table data... Friend, Is there a link attribute with every row of a table through which we will able to refresh a particular table row?ADS_TO_REPLACE_1 Please clarify
value is inserted into the sql table through jsp-jdbc but not getting stored into the data base,only row is increasing.
value is inserted into the sql table through jsp-jdbc but not getting stored into the data base,only row is increasing.  <html> <..."> <title>JSP Page</title> <style type
how to take input table name in jsp to create table in mysql?
how to take input table name in jsp to create table in mysql?  how to take input table name in jsp to create table in mysql?   Hello Friend, Try the following code:ADS_TO_REPLACE_1 <%@page import="java.sql.*"%>
Adding button to each row for the table and adding row to another table
Adding button to each row for the table and adding row to another table  Hi I need to add button to each line in the table(Table data is retrived... row of the table
Highlight a corresponding table row - Struts
and it has to find the correct page where the record is and highlight the correct row...Highlight a corresponding table row  I have 2 jsps... the table being displayed with rows having links in them(paged display
Insert specific fields into table dynamically for each row.
Insert specific fields into table dynamically for each row.  There is a table containing 20 fields and 2 of those are empty. The administrator... on done the values will be inserted into database.Then he enter values for next row
How to use next and previous button(or href) for database table that is retrieved from MySQL DB.
How to use next and previous button(or href) for database table that is retrieved from MySQL DB.  Initially,display 7or10 records on a jsp pageand when click on the NEXT button(or href link) then display next 7 records
How to compile & get output for JSP
How to compile & get output for JSP  HI My Roseindia friend has given the answer as RUN the JSP How to run the JSP Program? But what i mean is that i created a small jsp program in HTML and saved as Hello.jsp. And next i opened
unable to display table data on JSP page that is coming from mysql and servlet.
unable to display table data on JSP page that is coming from mysql and servlet.  I am unable to show table data on JSP page using servlet and mysql. only two rows data i showing but in my database I have five fields
unable to display table data on JSP page that is coming from mysql and servlet.
unable to display table data on JSP page that is coming from mysql and servlet.  I am unable to show table data on JSP page using servlet and mysql. only two rows data i showing but in my database I have five fields
unable to display table data on JSP page that is coming from mysql and servlet.
unable to display table data on JSP page that is coming from mysql and servlet.  I am unable to show table data on JSP page using servlet and mysql. only two rows data i showing but in my database I have five fields
how to get the checkbox value in jsp
how to get the checkbox value in jsp  how to get the checkbox value in jsp?   JSP CheckBox Example - how to get the checkbox value in jsp
session value not get in many jsp page.
session value not get in many jsp page.  I am using servlet to set...,response); and get session value on jsp page by follwing:- (adsbygoogle...)session.getAttribute("user"); this is work but when this code is use in other jsp page its give
JDBC Delete Row In Table Example
JDBC Delete Row In Table Example : In this tutorial we will learn how delete specific row from the table use mysql JDBC driver.This tutorial defined how one or more specific  row delete from table that follow any given condition
how to create database and table using jsp
how to create database and table using jsp  hi frnds...., i want to create database and table in mysql using jsp.... i have an registration form(name... table using jsp code... the table name should be the name of the person

Ads