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

 
 


Derrick Tan
get info from mysql using jsp and servlet
2 Answer(s)      10 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?

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 Pages:
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
Page Directive attribute - info
servlet or JSP. You will get information of that JSP using "... by using getServletInfo() method of Servlet interface. The value...Page Directive attribute - info This tutorial  contains description
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
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
The "isThreadSafe" & "info" Attribute of JSP page directive
a particular servlet or JSP. You will get information of that JSP using "...;info "attribute of JSP page directive. The "isThreadSafe"...The "isThreadSafe" & "info" Attribute of JSP page
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
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
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
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
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
student info
information using jsp and servelts   Hi Friend, Please visit the following links: http://www.roseindia.net/jsp/user-search.shtml http://www.roseindia.net/jsp/popup-window-using-ajax-in-jsp.shtml The above links will be helpful
jsp using include & with mysql
jsp using include & with mysql  Sir, I am creating a login application using jsp & Mysql. The Codes are--- Html File...... <...;/font> <br> <br> <form method="get" action="login.jsp"> Enter
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
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
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
how to fetch image from mysql using jsp
how to fetch image from mysql using jsp  how to fetch image from mysql using 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 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
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
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
jsp & mysql - JSP-Servlet
jsp & mysql  can anybody tell me hoe to overcome from following error i am facing this problem...plz help me... org.apache.jasper.JasperException: Communication failure during handshake. Is there a server running on localhost
get and display blob from mysql on jsf
get and display blob from mysql on jsf  i want to get blob from mysql, and display on jsf page. your examples with jsp. i dont find an example with jsf. plese help me about this. thanks..   Have a look at the following
JSP Get Data From Database
JSP Get Data From Database In this section we will discuss about how to get data from database using JSP. To get data from database to a JSP page we.... In my example I am using the MySQL database system and the provided driver
get a radio button click value - JSP-Servlet
servlet from another jsp i.e 'main.jsp', then you have to store the value of id in main.jsp using the following: In servlet, use the following code...") in servlet that is used in another jsp so can i call getParameter("radio") i.e
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
problem connect jsp and mysql - JSP-Servlet
problem connect jsp and mysql  hello, im getting an error while connecting jsp and mysql. I have downloaded the driver mysql-connector... Software Foundation\Tomcat 5.5\common\lib\mysql-connector-java-2.0.14.jar
fetch and insert multiple rows into mysql database using jsp servlet
fetch and insert multiple rows into mysql database using jsp servlet  ... jsp form and want inserting it into my mysql database table. but i am having... here is the code of both jsp and servlet <%@page contentType="text/html
jsp with mysql bolb - JSP-Servlet
jsp with mysql bolb  how to display images from mysql bolb in jsp?(in my selected area)  Hi friend.... http://www.roseindia.net/jsp/retrieve-image.shtml Thanks
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
MySql - JSP-Servlet
MySql  Hello friends, I am developing a JSP project with back end MYSQL and i am using SQLYOG editor enterprise 7.11. I got the serial number also...; Hi friend, http://www.roseindia.net/mysql/mysql-front.shtml Thanks
how to connect j2me program with mysql using servlet?
how to connect j2me program with mysql using servlet?  my program...()); os.flush(); os.close(); // Get the response from the servlet page. DataInputStream
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
interface to mysql - JSP-Servlet
interface to mysql  i am creating an easy accces to mysql through jsp-sevlets,when ever user enters the query through the interface how to retrieve the result from the database where the developer has to generally develope
How to get an Id vaue - JSP-Servlet
a respected cases.In that case i am calling a jsp by using a response.sendRedirect...How to get an Id vaue  Dear Sir, Thanks for posting...... In form action their is a servlet action when i clickon a button
js,,mysql - JSP-Servlet
js,,mysql  Hi, I want a jsp code for editing,deleting data retrieved from from the mysql database and displayed in a html page .Can anybody... link: http://www.roseindia.net/jsp/user-search.shtml Hope that the above
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
connection of jsp with mysql - JSP-Servlet
connection of jsp with mysql  can anybody tell me about connection of JSP with MYSQL? and also tell me which version is compatible with tomcat 4.1 i am using tomcat 4.1, MYSQL 5.0 but i have problem with connection
jsp-servlet - JSP-Servlet
jsp-servlet  what is the problem with using microsoft access as database? The sample example, i got from you is: database:mysql. One of my java faculty said, we cannot use ms-access as database because it has some dis-advantage
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
jsp code - JSP-Servlet
the second drop down list is displayed from mysql data base table by using select... to generate second drop down list by using jsp? pls ?   Hi Friend...jsp code  hi my requirement is generate dynamic drop down lists
Get Column names using Metadata in jsp
Get Column names using Metadata in jsp       This section illustrates you how to get column names from the database using metadata in jsp.  Here we are providing you
Doubt in using combination of JSP page and Java class. - JSP-Servlet
be disabled from clicking. How to go about doing this in a "JSP Page using...Doubt in using combination of JSP page and Java class.   I've got... to get the timeslot and other info. and then stored that in arraylist and transfered
mysql - JSP-Servlet
mysql  code to add photo in mysql database ... i want page from which i can upload photo which will store in mysql database and display in one page in jsp...  Hi Friend, Try the following code: 1)page.jsp
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
jsp/servlet - JSP-Servlet
jsp/servlet  Hello ! How can we call a servlet on a link on html page like a href="servletname"> Call Servlet Is it possible?   Hi friend, I am sending simple application using servlet. This is form
Backup MySQL Database - JSP-Servlet
Backup MySQL Database  Database Sir I have been reading Rose's india tutorial "Using MySQL Database with JSP/Servlet". In the Tutorial you have shown an example of backing up the database. When I tried to backup database
Sum - JSP-Servlet
Sum  Hi all, Please I need your help (source code) on how I can get the total sum of items from database using Java servlet or Jsp and html form.... Please the database I'm using is Microsoft Sql 2000 not MYSQL. Thank you all
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
passing value from javascript to jsp - JSP-Servlet
passing value from javascript to jsp  Hi... Is there any way to get the value from the javascript and print it on the current jsp page or print an array onto the current jsp page using javascript  Hi Friend, We

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.