Jdbc-servlet-jsp integration
Your current task is to insert Employee details at least 10 records into database and showing inserted results into the browser.
Things need to done:
Step 1: To insert details create one jsp with the following fields :
1.Employee.jsp:-
Employee Id(textbox)
Employee Name (Text box)
Designation (Dropdown)
Salary (textbox) ----- If you want to add any field then you can add it.
Note: - [Dropdown options like: Trainee Engineer, Software Engineer, Tech lead etc...]
2.EMPLOYEE Table :
Column Name Type Not Null Constraints Comments
Eid Number Yes Primary Key -
Ename Varchar2(50) Yes - -
Designation Varchar2(50) Yes - -
Sal Number Yes -
3. EmployeeServlet: this is the servlet where you can get the User interface details regarding the Employee and establishes the connection with the database, execute your queries ,setting your result set in request scope and displaying the results in results.jsp
Note: I recommend separate layer (class) to write the database logic so create one class to interact with the database and you can use the class in servlet by creating the object of the class
Example :
Class EmployeeServlet
{
service(-----)
{
EmployeeDao empDao=new EmployeeDao();
empDao.insertEmployee(--);
ResultSet rs=empDao.retrieve(--);
}
}
4.EmployeePojo.java :
I recommend its better to create this class to set all the user interface details to one object and pass this object to EmployeeDao
For Example :
service(-----)
{
String eid= request.getParameter(“eid”);
Employee empObj = new Employee();
empObj.setEid(eid); etc...
EmployeeDao empDao=new EmployeeDao()
empDao.insertEmployee(empObj);
}
5.EmployeeDao :
It contains connection logic and user defined methods to insert and retrieve the records.
6.result.jsp: it displays the result in table format