Saurav 3.2 Java
Saurav 3.2 Java
Saurav 3.2 Java
1. Aim-
Create an application for Online Auction using HTML and Servlet. Use the database to store and
retrieve records.
2. Objective –
Create a HTML Page, connect it to JDBC server and save information using servlets
3.Algorithm:
(a).
1. Turn On XAMPP Server
2. Create a New Database and a new table inside the Database
3. Add all the required Attribute fields
(b).
1. Build a HTML page with fields to fetch data and connect to Servlets
2. Inside Eclipse, create a new class inside the project
3. Built a connection with the mySQL Server
4. Using Prepared Statements Fetch information to and fro from the table.
4.Source Code:
Auction.html
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<form action="Auction_data" method="post">
Name:<input type="text" name="userName"/><br/><br/>
Product:
<select name="productName">
<option>Dell</option>
<option>HP</option>
<option>Sony</option>
<option>Lenevo</option>
</select>
<br/><br/>
</html>
Auction_data.java
import java.io.IOException;
import java.io.PrintWriter; import
java.sql.Connection; import
java.sql.DriverManager;
import java.sql.PreparedStatement; import java.sql.ResultSet;
import java.sql.Statement;
import javax.servlet.ServletException; import
javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest; import
javax.servlet.http.HttpServletResponse;
public class Auction_data extends HttpServlet { private static
final long serialVersionUID = 1L;
String
n=request.getParameter("userName"); String
p=request.getParameter("productName"); int
e=Integer.parseInt(request.getParameter("bidValue"));
try
{
Class.forName("com.mysql.jdbc.Dri ver");
Connection
"+rs.getInt(3));
con.close();
}