0

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>          
4
Contributors
4
Replies
17
Views
3 Years
Discussion Span
Last Post by peter_budo
0

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,...

1

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

0

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?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.