0% found this document useful (0 votes)
17 views3 pages

Index

The document contains code for an index.jsp page that displays a form for searching a database by first name. It also contains code for a search.jsp page that connects to an Oracle database, executes a SQL query to search for and return records matching the submitted first name, and displays the results in a table.

Uploaded by

Akbar Shaikh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views3 pages

Index

The document contains code for an index.jsp page that displays a form for searching a database by first name. It also contains code for a search.jsp page that connects to an Oracle database, executes a SQL query to search for and return records matching the submitted first name, and displays the results in a table.

Uploaded by

Akbar Shaikh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

index.

jsp

<!DOCTYPE html>

<html lang="en">

<head>

<title>Search Example</title>

<meta charset="utf-8">

<meta name="viewport" content="width=device-width, initial-scale=1">

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-


beta.2/css/bootstrap.min.css">

</head>

<body>

<div class="container">

<form class="form-inline" method="post" action="s.jsp">

<input type="text" name="Firstname" class="form-control" placeholder="First Name..">

<button type="submit" name="save" class="btn btn-primary">Search</button>

</form>

</div>

</body>

</html>

Search.jsp

<%@page import="java.sql.*"%>

<%

Class.forName("oracle.jdbc.driver.OracleDriver");

Connection conn =
DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:XE","system","system");

Statement st=conn.createStatement();

String firstname=request.getParameter("firstname");
try {

Class.forName("oracle.jdbc.driver.OracleDriver");

} catch (ClassNotFoundException e) {

e.printStackTrace();

%>

<!DOCTYPE html>

<html>

<body>

<h1>Search Data</h1>

<table border="1">

<tr>

<td>first Name</td>

<td>Last Name</td>

<td>E-mail</td>

<td>Password</td>

<td>Company</td>

<td>Job Description</td>

<td>Address</td>

<td>Pin</td>

<td>Mobile</td>

</tr>

<%

try{

conn = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:XE","system","system");
String sql ="select * from signin where firstname="+firstname+"'";

ResultSet rs= st.executeQuery(sql);

while(rs.next()){

%>

<tr>

<td><%=rs.getString("Firstname") %></td>

<td><%=rs.getString("Lastname") %></td>

<td><%=rs.getString("Email") %></td>

<td><%=rs.getString("Password") %></td>

<td><%=rs.getString("Companyname") %></td>

<td><%=rs.getString("jobdescription") %></td>

<td><%=rs.getString("address") %></td>

<td><%=rs.getString("country") %></td>

<td><%=rs.getString("state") %></td>

<td><%=rs.getString("pincode") %></td>

<td><%=rs.getString("mobilenumber") %></td>

</tr>

<%

conn.close();

} catch (Exception e) {

e.printStackTrace();

%>

</table>

</body>

</html>

You might also like