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>          

Recommended Answers

All 4 Replies

data should not going to store in database.. lost 5hours im getting this error man,... very urgently now i want show my senior programmer,...

please any one help me out,...

Sorry, until you get rid of those scriptlets and program your JSPs PROPERLY, I am keeping quiet.

did you add the right libraries to your (project's) path?
anyway ... are you sure you want to show code like thát to a senior developer?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.