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



Home Answers Viewqa JSP-Servlet Retrieve data by clicking a link
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


Nandini Mishra
Retrieve data by clicking a link
2 Answer(s)      3 years and 7 months ago
Posted in : JSP-Servlet


In a page there are 5 links.Every link has a hidden value. According to that hidden value data should be retrieved from the database and data should be displayed in a new page.How to do it?Please help.


Advertisement
View Answers

May 24, 2011 at 12:32 PM


1)link.jsp:

<a href="display.jsp?id=1">Link1 </a><br>
<a href="display.jsp?id=2">Link2 </a><br>
<a href="display.jsp?id=3">Link3 </a><br>
<a href="display.jsp?id=4">Link4 </a><br>
<a href="display.jsp?id=5">Link5 </a>

2)display.jsp:

<%@page import="java.sql.*"%>
<table>
<%
String id=request.getParameter("id");
Class.forName("com.mysql.jdbc.Driver").newInstance();  
 Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/test","root","root");  
Statement st=con.createStatement();
ResultSet rs=st.executeQuery("Select * from employee where id='"+id+"'");
if(rs.next()){
    %>
<tr><td>Name:</td><td><input type="text"  value="<%=rs.getString("name")%>"></td></tr>
<tr><td>Address:</td><td><input type="text"  value="<%=rs.getString("address")%>"></td></tr>
<tr><td>Contact No:</td><td><input type="text" value="<%=rs.getString("contactNo")%>"></td></tr>
<tr><td>Email:</td><td><input type="text" value="<%=rs.getString("email")%>"></td></tr>
<%
}
%>
</table>


May 24, 2011 at 12:32 PM


1)link.jsp:

<a href="display.jsp?id=1">Link1 </a><br>
<a href="display.jsp?id=2">Link2 </a><br>
<a href="display.jsp?id=3">Link3 </a><br>
<a href="display.jsp?id=4">Link4 </a><br>
<a href="display.jsp?id=5">Link5 </a>

2)display.jsp:

<%@page import="java.sql.*"%>
<table>
<%
String id=request.getParameter("id");
Class.forName("com.mysql.jdbc.Driver").newInstance();  
 Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/test","root","root");  
Statement st=con.createStatement();
ResultSet rs=st.executeQuery("Select * from employee where id='"+id+"'");
if(rs.next()){
    %>
<tr><td>Name:</td><td><input type="text"  value="<%=rs.getString("name")%>"></td></tr>
<tr><td>Address:</td><td><input type="text"  value="<%=rs.getString("address")%>"></td></tr>
<tr><td>Contact No:</td><td><input type="text" value="<%=rs.getString("contactNo")%>"></td></tr>
<tr><td>Email:</td><td><input type="text" value="<%=rs.getString("email")%>"></td></tr>
<%
}
%>
</table>


Related Tutorials/Questions & Answers:
Retrieve data by clicking a link
Retrieve data by clicking a link  In a page there are 5 links.Every link has a hidden value. According to that hidden value data should be retrieved from the database and data should be displayed in a new page.How to do it?Please
link in the field of table on clicking he link the full data will displayed
link in the field of table on clicking he link the full data will displayed   Hello... I am learning jsp and mysql. I am facing some problem. I am... that on clicking on any one of the name of the student, the whole data
Advertisements
retrieve the data to text fields from database on clicking the value of combo box
retrieve the data to text fields from database on clicking the value of combo box   retrieve the data to text fields from database on clicking... getting data into textarea from database table by clicking on the button
how to retrieve link - JSP-Servlet
how to retrieve link  how to retrieve link of a web page and use it as input in the program
Display alert box on clicking link
Display alert box on clicking link In this tutorial, we will display alert box... a "a href" link. On clicking this link ,a alert box prompt message... is used to display alert box on clicking link : $("a").click(function
How to read and retrieve jtable row values into jtextfield on clicking at particular row ...
How to read and retrieve jtable row values into jtextfield on clicking at particular row ...  Hello Sir, I am developing a desktop application in which i have to display database records in jtable .now I want
store and retrieve data
store and retrieve data  sir,i want to store the entering data in a word file and retrieve it when i need.i am try to develop a video portal.in which... Write data into word file For this, poi-scratchpad-3.7-20101029.jar is needed
how to retrieve data from database ?????/
how to retrieve data from database ?????/  how to retrieve data from database
how to retrieve data from database ?????/
how to retrieve data from database ?????/  how to retrieve data from database
how to retrieve data from database ?????/
how to retrieve data from database ?????/  how to retrieve data from database
how to retrieve data from database ?????/
how to retrieve data from database ?????/  how to retrieve data from database
how to retrieve data from database
how to retrieve data from database  unable to retrieve data from database using mySQL by using jsp sessions and beans for editing
how to store,retrieve,modify the data
how to store,retrieve,modify the data  hello sir ,how to store,retrieve,modify the data using the swing please help me
Retrieve The Data From MySql Datbase
Retrieve The Data From MySql Datbase   How to Retrieve The Data From MYSQL database TO Use Select the Emp_id Option.And Also Search Option
How to Retrieve Data from Facebook Using PHP
How to Retrieve Data from Facebook Using PHP  is this link has right content regards that?? http://techpdf.co.cc/blog/how-to-retrieve-data-from-facebook-using-php
How to Retrieve Data from Facebook Using PHP
How to Retrieve Data from Facebook Using PHP  is this link has right content regards that?? http://techpdf.co.cc/blog/how-to-retrieve-data-from-facebook-using-php
retrieve data from database with hyperlink
retrieve data from database with hyperlink  sir....i have one table called 'name' having two values i have to retrieve those data with a hyperlink... have values C C++ i have to retrieve and if i click C its sub categories should
Retrieve data using Criteria api
Retrieve data using Criteria api  import org.hibernate.Session; import org.hibernate.SessionFactory; import org.hibernate.Query; import... the following link: Hibernate Tutorials
retrieve data from mysql database
retrieve data from mysql database  hi am not familiar in php.....even... selected value on combobox which is to be retrieve the relevant data from mysql...;'; } ?&gt; finally the result is whole data is displayed where the data
retrieve data into textbox - Swing AWT
retrieve data into textbox  Hi! I am writing a program using java swing to create a front end in which a user enters his name and roll no. and gets... there is a table called student in which all records are kept..how can i retrieve
link
link  hey frnds can anyone plz tell me how can i store my videos as link in my database and can retrive the video using servlet by clicking on to that link .it may be confusing sorry about that and if someone can than plz help me
Data retrieve from mysql database
Data retrieve from mysql database  Hi sir, please give some example... from the dropdown, related data will get displayed on the textboxes. Here we have...("name").toString(); String data=""; Connection conn = null; String url = "jdbc
how to use bean to retrieve data from database
how to use bean to retrieve data from database  how to use bean to retrieve data from database   poda sendru
how to retrieve blob data - JSP-Servlet
how to retrieve blob data  How to retrieve the BLOB table having... as a table format?   Hi friend, I am sending you a link. I hope that, this link will help you. Please visit for more information. http
Retrieve multiple data from database into Table.....
Retrieve multiple data from database into Table.....   hi........... I want to Retrieve multiple data from database into Table but i am not able to.... i am only able to retrieve one value not more than that. means in my
retrieve data from database using jsf
retrieve data from database using jsf  Hello I want an example of source code to retrieve data from database i have a database (oracle) name as db1...),, name ,and city I want after enter value in textbox according idauthor i retrieve
JSP and XML .data store nd retrieve
JSP and XML .data store nd retrieve  I have made a form in jsp having emp id, projectname and emp name.I want to store data related to employee in xml file.How can i store data entered by user in XML file and later retrieve data
link
link  how can we give hyperlinks on data retrieved from the database... and details related to that link should be diaplay and stored in the database... which when clicked displays some data and "conference " is stored in another
MYSQL retrieve record from Data table
MYSQL retrieve record from Data table  Hi. I have a field in database named stages. its datatype is varchar(60). It contains values chennai,trichy,kanchipuram for a single record. I have to retrieve these data from the field
I have to retrieve these data from the field table
I have to retrieve these data from the field table  Hi. I have a field in database named stages. its datatype is varchar(60). It contains values chennai,trichy,kanchipuram for a single record. I have to retrieve these data from
Retrieve data from xml using servlets
Retrieve data from xml using servlets  Hi plz send me the code for retrieving the data from xml File using Servlets.   Hi, Do you want... Thanks   Hi, Learn Get Data From the XML File. Thanks
 

 

 

DMCA.com