Adbms 9101 Ca2
Adbms 9101 Ca2
PROJECT REPORT ON
IN PARTIAL FULFILLMENT OF
SEMESTER V 2024-25
PROJECT GUIDE
• Session Management:
o The application uses session management to maintain
user states, such as login status and user-specific
messages (e.g., success or error messages).
• Data Validation:
o Input validation is performed to ensure that the data
entered by users meets the required criteria before being
processed and stored in the database.
CODE :
Spring-servlet.xml
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:util="http://www.springframework.org/schema/util"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/contex t"
xmlns:mvc="http://www.springframework.org/schema/mvc "
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/springbeans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/springcontext.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/springmvc.xsd">
<!-- Component scan -->
<bean name="viewResolver"
class="org.springframework.web.servlet.view.InternalResourceVi
ewResolver">
<property name="prefix" value="/WEB-INF/views/" />
</bean>
<tx:annotation-driven/>
<bean name="ds"
class="org.springframework.jdbc.datasource.DriverManagerData
Source">
<property name="driverClassName"
value="com.mysql.cj.jdbc.Driver"/>
<property name="url"
value="jdbc:mysql://localhost:3306/spring_orm"/>
<property name="username" value="root"/>
<property name="password" value="admin"/>
</bean>
<bean name="factory"
class="org.springframework.orm.hibernate5.LocalSessionFactor
yBean">
<property name="dataSource" ref="ds"/>
<property name="hibernateProperties">
<props>
<prop
key="hibernate.dialect">org.hibernate.dialect.MySQL57Dialect</
prop>
<prop key="hibernate.hbm2ddl.auto">update</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.format_sql">true</prop>
<prop key="hibernate.use_sql_comments">true</prop>
</props>
</property>
<property name="annotatedClasses">
<list>
<value>com.becoder.entity.Emp</value>
</list>
</property>
</bean>
<bean name="hibernateTemplate"
class="org.springframework.orm.hibernate5.HibernateTemplate"
>
</bean>
<bean name="transactionManager"
class="org.springframework.orm.hibernate5.HibernateTransactio
nManager">
<property name="sessionFactory" ref="factory"/>
</bean>
</beans>
Home controller.java
package com.becoder.controller;
import
org.springframework.stereotype.C
ontroller; import
org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import java.util.List; // Correct import for Java List
import com.becoder.dao.EmpDao; import
com.becoder.entity.Emp;
import javax.servlet.http.HttpSession;
import org.springframework.beans.factory.annotation.Autowired;
@Controller
@Autowired private
EmpDao empDao;
@RequestMapping(path = "/home") public String
home(Model m) {
m.addAttribute("empList" , list);
@RequestMapping(path = "/addEmp")
public String addEmp() {
return "addEmp"; // This should resolve to /WEB-
INF/views/add_Emp.jsp
int i = empDao.saveEmp(emp);
session.setAttribute("msg","Resgister Successfully");
return"redirect:/addEmp";
@RequestMapping(path = "/editEmp/{id}")
m.addAttribute("emp",emp);
return "edit_emp";
}
session.setAttribute("msg","Update Succesfully");
return "redirect:/home";
}
@RequestMapping("/deleteEmp/{id}")
Addemp.jsp
pageEncoding="UTF-8"%>
<%@page isELIgnored="false"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Add Employee</title>
<link
href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/boot
strap.min.css" rel="stylesheet" crossorigin="anonymous">
</head>
<body>
<div class="container-fluid">
</button>
<li class="nav-item">
<li class="nav-item">
</li>
</ul>
</div>
</div>
</nav>
<div class="container">
<div class="row">
<div class="card">
<h2>Add Employee</h2>
</c:if>
</div>
<div class="card-body">
<div class="mb-3">
<div class="mb-3">
<div class="mb-3">
<div class="mb-3">
<div class="mb-3">
<div class="mb-3">
</div>
</div>
</div>
</div>
</div>
</html>
Home.jsp
<%@page isELIgnored="false"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<link
href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/boot
strap.min.css" rel="stylesheet" crossorigin="anonymous">
<style>
body {
background-
color: #f8f9fa;
/* Light
background
color */
.card-header {
.success-message {
.error-message {
</style>
</head>
<body>
<div class="container-fluid">
<a class="navbar-brand" href="#">Employee Management
System</a>
</button>
<li class="nav-item">
</li>
<li class="nav-item">
</li>
</ul>
</div>
</div>
</nav>
<div class="container mt-4">
<div class="row">
<div class="col-md-12">
<div class="card">
<div class="card-header">
<h5 class="success-message">${msg}</h5>
<c:remove var="msg"/>
</c:if>
</div>
<div class="card-body">
<thead>
<tr>
<th scope="col">Id</th>
<th scope="col">Address</th>
<th scope="col">Email</th>
<th scope="col">Password</th>
<th scope="col">Designation</th>
<th scope="col">Salary</th>
<th scope="col">Action</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row">${emp.id}</th>
<td>${emp.fullname}</td>
<td>${emp.address}</td>
<td>${emp.email}</td>
<td>${emp.password}</td>
<td>${emp.designation}</td>
<td>${emp.salary}</td>
<td>
</tr>
</c:forEach>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
<script
src="https://cdn.jsdelivr.net/npm/@popperjs/[email protected]/dist/um
d/popper.min.js" crossorigin="anonymous"></script>
<script
src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstr
ap.min.js" crossorigin="anonymous"></script>
</body>
</html>
Edit_emp.jsp
<%@page isELIgnored="false"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Add Employee</title>
<link
href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/boot
strap.min.css" rel="stylesheet" crossorigin="anonymous">
</head>
<body>
<div class="container-fluid">
</button>
<div class="collapse navbar-collapse"
id="navbarSupportedContent">
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
<li class="nav-item">
<li class="nav-item">
</li>
</ul>
</div>
</div>
</nav>
<div class="container">
<div class="row">
<div class="card">
<h2>Edit Employee</h2>
<c:remove var="msg"/>
</c:if>
</div>
<div class="card-body">
<form
action="${pageContext.request.contextPath}/updateEmp"
method="post">
<input type="hidden" name="id" value="${emp.id }">
<div class="mb-3">
<div class="mb-3">
</div>
<div class="mb-3">
<div class="mb-3">
<div class="mb-3">
<div class="mb-3">
</div>
</div>
</div>
</div>
</div>
</div>
<script
src="https://cdn.jsdelivr.net/npm/@popperjs/[email protected]/dist/um
d/popper.min.js" crossorigin="anonymous"></script>
<script
src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstr
ap.min.js" crossorigin="anonymous"></script>
</body>
</html>
Empdaoimpl.java package
com.becoder.dao;
import java.util.List;
import javax.transaction.Transactional;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.orm.hibernate5.HibernateTemplate;
import org.springframework.stereotype.Repository;
import com.becoder.entity.Emp;
@Repository
@Autowired
private HibernateTemplate hibernateTemplate;
@Transactional
return i;
return emp;
List<Emp> list=hibernateTemplate.loadAll(Emp.class);
return list;
}
@Transactional
Emp.java
package com.becoder.entity;
return id;
this.id = id;
return fullname;
return address;
return password;
Output :
Database output :
PLSQL QUERIES
USE VIEW :
USE FUNCTION :