Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa JSP-Servlet How to get table row contents into next jsp page

Have Programming Question? Ask it here!
 
 
 


vikas
How to get table row contents into next jsp page
2 Answer(s)      2 years ago
Posted in : JSP-Servlet


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


Advertisement
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 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 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
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 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
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
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
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 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 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
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
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 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
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 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 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
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
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 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
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
PHP file_get_contents() Function
PHP file_get_contents() Function  Hi, How do i read the content of file using PHP program? So kindly provide any example or online help reference for filegetcontents() Function in PHP. Please feel free to suggest. Thanks
Java get Next Day
Java get Next Day       In this section, you will study how to get the next day in java... DateFormatSymbols in order to get the names of the days of the week. The method getWeekdays
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 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
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
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
pass to next page
pass to next page  I am working on a school project no server client side only. 1st page you enter data such as name, address, DoB etc.(textboxes... on 2nd page like a summary (too many fields for cookies) all the code i am finding
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
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
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? Please clarify this. Thanks
The PHP file_get_contents() function , file_get_contents php
The PHP file_get_contents() Function Function reads the content... is supported by the servers. So, the use of file_get_contents() will make your program... the contents of the file no need of loop Syntax of file_get_contents() Function
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:- String user=(String)session.getAttribute("user"); this is work but when this code is use in other jsp
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
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
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
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
display all the values on next page
values are inserting in the database and i am moving on another page after doing some functionality on next page i am returning on my first page and i want...display all the values on next page  i am inserting values
How to work with POST method in jsp page
How to work with POST method in jsp page       This is detailed JSP code, how to use POST method instead of GET method in jsp page. GET is default method for sending
How to get the output of JSP program using Bean
How to get the output of JSP program using Bean  Hi Kindly go...;</tr> </table </BODY> </HTML> Next i created JSP... created in Java and compiled <%@ page language="java" import="beans" %>
How to get a values - JSP-Servlet
How to get a values  Dear sir, I have one input text field and one submit button .Within one file how to get a values within a same jsp. Thanks and Regards Harini Veerapur.  Hi Friend, Try the following
JDBC Get Row Count
in JDBC Get Row Count. The code help you to understand how to count the number... JDBC Get Row Count       The JDBC Get Row Count enables you to return the row count of a query. JDBC Get Row
 

 

 

DMCA.com