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



Home Answers Viewqa JSP-Servlet get info from mysql using jsp and servlet
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


Derrick Tan
get info from mysql using jsp and servlet
2 Answer(s)      2 years and 5 months ago
Posted in : JSP-Servlet


HELLO! I wanna create a jsp page which able to let me get its name, phone and other info by asking the user to key in their email address from mysql database by using servlet and jsp too. Can anyone let me know any of its tutorial link?


Advertisement
View Answers

July 9, 2012 at 3:38 PM


Here is an application that ask the user to enter email-id. According to that data will get retrieved from database.

1)search.jsp:

<html>
<head>
</head>
<body>
<br><br><br><br><br><br>
<form method="post" name="frm" action="..//search">
<table border="0" width="300" align="center" bgcolor="#CDFFFF">
<tr><td colspan=2 style="font-size:12pt;color:#00000;" align="center">
<h3>Search Form</h3></td></tr>
<tr><td ><b>Enter Email</b></td>
<td>: <input type="text" name="email" id="email">
</td></tr>
<tr><td colspan=2 align="center">
<input type="submit" name="submit" value="Search"></td></tr>
</table>
</form>
</body>
</html>

2)Search.java:

import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import javax.sql.*;
import java.sql.*;
import java.util.*;

public class Search extends HttpServlet{

public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException,IOException{
response.setContentType("text/html");
PrintWriter out = response.getWriter();

System.out.println("MySQL Connect Example.");
Connection conn = null;
String url = "jdbc:mysql://localhost:3306/";
String dbName = "register";
String driver = "com.mysql.jdbc.Driver";
String userName = "root";
String password = "root";


Statement st;
try {
Class.forName(driver).newInstance();
conn = DriverManager.getConnection(url+dbName,userName,password);
System.out.println("Connected to the database");
String email = request.getParameter("email");
String query = "select * from item where email='"+email+"'";
st = conn.createStatement();
ResultSet rs = st.executeQuery(query);
out.println("<table border='1'>
while(rs.next()){
out.println("<tr><td>First Name</td><td><td><input type='text' value="+rs.getString(1)+"></td></tr>");
out.println("<tr><td>Last Name</td><td><td><input type='text' value="+rs.getString(2)+"></td></tr>");
out.println("<tr><td>Address</td><td><td><input type='text' value="+rs.getString(3)+"></td></tr>");
out.println("<tr><td>Contact No</td><td><td><input type='text' value="+rs.getString(4)+"></td></tr>");

}
out.println("</table>");
conn.close();
System.out.println("Disconnected from database");
} catch (Exception e) {
e.printStackTrace();
}
}
}

3)web.xml:

<servlet-name>Search</servlet-name>
<servlet-class>Search</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Search</servlet-name>
<url-pattern>/search</url-pattern>
</servlet-mapping>


February 7, 2013 at 9:00 AM


mysql-connector-java-5.1.20-bin



Related Tutorials/Questions & Answers:
get info from mysql using jsp and servlet
get info from mysql using jsp and servlet  HELLO! I wanna create a jsp page which able to let me get its name, phone and other info by asking the user to key in their email address from mysql database by using servlet and jsp too
seeking info - JSP-Servlet
seeking info  Looking for the information on Java, JSP and Servlet... and JSP-Servlet Programs.Then check your program for all necessary files.I guess this would solve your problem.for further query read RoseIndia JSP and Servlet
Advertisements
Retrieve hardware info of a PC using servlet - JSP-Servlet
Retrieve hardware info of a PC using servlet  Hi,I hav a query related to java servlets.I wanted to know how to retrieve the hardware information using java servlets?I had gone through this link http://www.roseindia.net/software
How to get the data from the database using Servlet or JSP program
How to get the data from the database using Servlet or JSP program  ... the problem   Get data from database using servlet Retrieve data from database using JSP Get data from database using JSP
retrive the employee details with image from mysql database using jsp servlet
retrive the employee details with image from mysql database using jsp servlet  im doing the web project to retrive the employee profile which i stored in the database using jsp servlet then want to show the result in the next jsp
retrieving info from DB using struts?
retrieving info from DB using struts?  Hi. I was looking info about retrieving info from a database using struts. I need a .java that I suppose connects to a database and show the info on a jsp. Somebody could help me
how to get harddisk info using S.M.A.R.T using java
how to get harddisk info using S.M.A.R.T using java   how to get harddisk info using S.M.A.R.T using java
how to fetch image from mysql using jsp
how to fetch image from mysql using jsp  how to fetch image from mysql using jsp
How to get the data from the database (Oracle) in console or in ie using servlet or jsp as Front end
How to get the data from the database (Oracle) in console or in ie using servlet or jsp as Front end  hello i have a simple problem in jsp in the sense to get data from the database like oracle . I have created one jsp
Get values from JSP pages - JSP-Servlet
Get values from JSP pages  I have welcome.jsp in which it has... I need to get the value of those column names(First Name, Second Name, City, State) into into next jsp page. note these are not Text fields
How to get jSon object in servlet from jsp - JSP-Servlet
How to get jSon object in servlet from jsp  How to get jSon object in servlet from jsp? In jsp page i have written: var sel...; var url = 'ConfigurationServlet?ActionID=Configuration_Physical_Get
how to get data from checkboxes - JSP-Servlet
how to get data from checkboxes  hi, i got list of tables on screen by invoking webservices.when the user selects the tables by using checkboxes, i need to get only those tables to the next page where i can get list of columns
to get picture from ms access database by jsp-servlet....
to get picture from ms access database by jsp-servlet....  I have inserted a picture in ms access data base,,,how we can retrieve that picture by using jsp
Exporting data from mysql into csv using jsp
Exporting data from mysql into csv using jsp  Hi friends.... I want to export the data from mysql to csv file using... i am having 30 columns in my... want csv file with 10 rows.. i want to do in jsp... pls help me soon..its very
how to get a values from processRecord - JSP-Servlet
how to get a values from processRecord  dear sir, i have a problem in getting a values from java to jsp.Here jsp is used to read a excel sheet...... thanks in advance.. //in jsp FileInputStream fin = new FileInputStream
not able to get values from jsp file - JSP-Servlet
not able to get values from jsp file  hi thanks for u feedback, her am sending the file jsp and servlet but in the servlet file am not able to get the value by using method request.getParameter(). it shows null value,but if i
unable to retrive the data from mysql using servlet using jdbc driver
unable to retrive the data from mysql using servlet using jdbc driver  Hi, i have a servlet program..to verify the login and redirect to correct..., HttpServletResponse response) throws ServletException,IOException { // Get
Image upload in mysql database using jsp servlet
Image upload in mysql database using jsp servlet  Hello, I need code to insert image in mysql database, I have seen the code which is already in your... located inside the application, but i need to upload in mysql and also for inserting
Image retrieval from mysql - JSP-Servlet
Image retrieval from mysql  Hai friends, I used the following code to insert image into mysql db. Db data type is blob. Database connection codings are in different file which is to be included
Upload Exce Data into MySql Using Jsp and Servlet - JSP-Servlet
Upload Exce Data into MySql Using Jsp and Servlet  now i am doing... into Mysql Database table so please give the coding to me, it's very urgent for me... the following link: http://www.roseindia.net/jsp/upload-insert-csv.shtml Hope
access image from ajax store in mysql using jsp
access image from ajax store in mysql using jsp  access image from ajax store in mysql using jsp (code to access image captured by camera and store in mysql
How to get data from DB in to Text box by using Jsp & Ajax
How to get data from DB in to Text box by using Jsp & Ajax   I want to get the data from database in to text box in a jsp page by using Ajax. If I... with a and from that i need to select the required value and i should store
How to get data from Oracle database using JSP
the answer to retrieve data from the database by using servlet or jsp program...How to get data from Oracle database using JSP  hello i have a simple problem in jsp in the sense to get data from the database like oracle . I have
Populate dropdown menu from database using jsp and servlet
Populate dropdown menu from database using jsp and servlet  please i need code to populate dropdown menu from mysql database using jsp and servlet. thanks
JSP-Mysql - JSP-Servlet
JSP-Mysql  Hello friends, Anyone send me the way how to store image in mysql database from a jsp page.  Hi friend, Code to insert image in mysql Using Jsp : For more information on JSP
The info Attribute of page Directive In JSP
The info Attribute of page Directive In JSP  ... about the info attribute of the page directive in JSP. This attribute simply sets the information of the JSP page which is retrieved later by using
retrieve related data from database using jsp and mysql
retrieve related data from database using jsp and mysql  Hi sir, please give some example of jsp code for retrieving mysql database values in multiple dropdown list. if we change a value in a dropdown its related value must
how to get a numeric value from a message - JSP-Servlet
how to get a numeric value from a message  dear sir, I have to get a numeric value from a following message matter i.e Dear [1... is in a text box am getting this message using //following code
Data needs to be gathered in XML file from the database (MySql) using JSP
data regarding particular id from the database table. Data needs to be gathered in XML file from the database (MySql) using appropriate JSP/Java Bean functions...Data needs to be gathered in XML file from the database (MySql) using JSP 
how to get a values from a multipart/form-data - JSP-Servlet
how to get a values from a multipart/form-data  Dear sir , I...: From: Matter : Status... ,matter,file field values but not status and from field i am getting null
How to get the values from the Combo Box - JSP-Servlet
How to get the values from the Combo Box   Sir, Actually i am getting the values in the combo box from table.I want what ever... in their respective text box. e.g suppose i select ram values from the combo box and its
 

 

 

DMCA.com