this front page:
Form.jsp
<html>
<head>
<title>
Data Inserting Form
</title>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
</head>
<body>
<h1>ENTER THE EMPLOYEE DETAILS</h1>
<form action="./Insert.jsp" method="post">
<table cellspacing="5" cellpadding="5" border="5">
<tr>
<td align="right">Employee Name:</td>
<td><input type="text" name="EmployeeName"></td>
</tr>
<tr>
<td align="right">Employee_id:</td>
<td><input type="text" name="Employee_id"></td>
</tr>
<tr>
<td align="right">Nationality:</td>
<td><input type="text" name="Nationality"></td>
</tr>
</table>
<input type="submit" value="submit">
</form>
</body>
</html>
Insert.jsp:
<html>
<head>
<title>
Inserting Data
</title>
<meta http-equiv="Content-type" content="text/html; charset=iso-8859-1">
</head>
<body>
<%@ page import="java.sql.*" %>
<%@ page import="java.sql.DriverManager.*" %>
<%@ page import="java.sql.Statement.*" %>
<%@ page import="java.io.*" %>
<%
String driverName="com.mysql.jdbc.Driver";
String connectionUrl="jdbc:mysql://localhost:3306/";
String user="root";
String password="sarakrish";
String dbName="employee";
String EmployeeName=request.getParameter("EmployeeName");
int Employee_id=Integer.parseInt(request.getParameter("Employee_id"));
String Nationality=request.getParameter("Nationality");
try{
Class.forName(driverName).newInstance();
Connection con=DriverManager.getConnection(connectionUrl+dbName,user,password);
Statement st=con.createStatement();
String sql ="SELECT * FROM employees";
ResultSet rs=st.executeQuery(sql);
out.println("database opened.");
}
catch(ClassNotFoundException e)
{
out.print("ClassNotFoundException:"+e.getMessage());
e.printStackTrace();
}
%>
</body>
</html>