SlideShare a Scribd company logo
1 of 72
Download to read offline
www.globsynskills.com 1
Document sign date :11 Jul, 2015
www.globsynskills.com 2
Globsyn Skills, Globsyn Crystals, 1
st
Floor, XI – 11 and 12, Block EP, Sector V, Salt Lake, Kolkata – 700091
MNREGA PORTAL USING JEE
Document sign date :11 Jul, 2015
www.globsynskills.com 3
Group Members:
MANISHA AGARWAL,JALPAIGURI GOVT. ENGG. COLLEGE,REG NO.131010110092
ANWESHA BHOWMIK,JALPAIGURI GOVT. ENGG. COLLEGE,REG NO.131010110068
ATANU DEB,JALPAIGURI GOVT. ENGG. COLLEGE,REG NO.131010110073
KRITI PAL,JALPAIGURI GOVT. ENGG. COLLEGE,REG NO.131010110016
MADHUMITA DAS,JALPAIGURI GOVT. ENGG. COLLEGE,REG NO.131010110018
Table of Contents
Acknowledgement .................................................................................................................................. 5
Project objective…..……………………………………………………………………………………………………………………………5
Project Scope .......................................................................................................................................... 5
Requirement Specification...................................................................................................................... 6
Database Design...................................................................................................................................... 7
Application Work Flow............................................................................................................................ 8
E-R Diagram……………………………………………………………………………………………………………………………………….9
Screenshots...................................................................................................................................... 10-14
Document sign date :11 Jul, 2015
www.globsynskills.com 4
Future Scope of Improvements ............................................................................................................ 15
Code ................................................................................................................................................. 17-66
Certificate…………………………………………………………………………………………………………………………………..67-71
Document sign date :11 Jul, 2015
www.globsynskills.com 5
Acknowledgement
I take this opportunity to express my profound gratitude and deep regards to my faculty Mr. Bhavesh
for his exemplary guidance, monitoring and constant encouragement throughout the course of this
project. The blessing, help and guidance given by him time to time shall carry me a long way in the
journey of life on which I am about to embark.
I am obliged to my project team members for the valuable information provided by them in their
respective fields. I am grateful for their cooperation during the period of my assignment.
MANISHA AGARWAL
ANWESHA BHOWMIK
ATANU DEB
Document sign date :11 Jul, 2015
www.globsynskills.com 6
KRITI PAL
MADHUMITA DAS
Project Objective
Development and implementation of an online management system for the MAHATMA GANDHI
NATIONAL RURAL EMPLOYMENT GUARANTEE ACT (MNREGA).
This system will provide the organization a systematic way of allowing users to
• Add projects
• Add employees
• Keep track of count of employees
• Keep track of count of projects
Document sign date :11 Jul, 2015
Edited with the trial version of
Foxit Advanced PDF Editor
To remove this notice, visit:
www.foxitsoftware.com/shopping
www.globsynskills.com 7
Project Scope
 BDO and GPM can login their respective account with their User name and password.
 BDO can create projects and GPMS can allocate projects and also can see the details of the
employees.
 GPM can create employees and enlist their details in the system and allocate project to them
for work.
Requirement Specification
Document sign date :11 Jul, 2015
www.globsynskills.com 8
HARDWARE:
1. Windows 7 (OS)
2. 4GB RAM
SOFTWARE:
1. Eclipse Luna
2. Wildfly 8.1.0.Final
3. jdk-8u25-windows-x64
Document sign date :11 Jul, 2015
www.globsynskills.com 9
Database Design
Document sign date :11 Jul, 2015
www.globsynskills.com 10
Application Work Flow
Document sign date :11 Jul, 2015
www.globsynskills.com 11
E-R Diagram
Document sign date :11 Jul, 2015
www.globsynskills.com 12
Screenshots
Homepage, BDO Homepage,Form of project details
Document sign date :11 Jul, 2015
www.globsynskills.com 13
Form of project details, List of Projects,Form of Project Details
Document sign date :11 Jul, 2015
www.globsynskills.com 14
Project Details, Form of Remove Project, Homepage
Document sign date :11 Jul, 2015
www.globsynskills.com 15
Gram Panchayet Homepage, Form for Register employee, List of Employee
Document sign date :11 Jul, 2015
www.globsynskills.com 16
Document sign date :11 Jul, 2015
www.globsynskills.com 17
Future Scope of Improvements
• Registration of multiple B.D.O.
• Auto-calculation of wages for employees.
• Auto-calculation of number of days for a project.
• Auto-calculation of number of days worked by an employee
Document sign date :11 Jul, 2015
www.globsynskills.com 18
Code
Core Model:-
Bean Classes:-
Employee class-
package com.vt.project.beans;
import java.util.Date;
public class Employee {
private int e_id;
private String e_name;
private long e_contact;
private int e_age;
private String e_address;
Project project;
public Employee(){}
public Employee(int e_id, String e_name, long e_contact, int e_age,
String e_address, Project project) {
super();
this.e_id = e_id;
this.e_name = e_name;
this.e_contact = e_contact;
this.e_age = e_age;
this.e_address = e_address;
this.project = project;
}
public int getE_id() {
return e_id;
}
public void setE_id(int e_id) {
this.e_id = e_id;
}
public String getE_name() {
return e_name;
}
public void setE_name(String e_name) {
Document sign date :11 Jul, 2015
www.globsynskills.com 19
this.e_name = e_name;
}
public long getE_contact() {
return e_contact;
}
public void setE_contact(long e_contact) {
this.e_contact = e_contact;
}
public int getE_age() {
return e_age;
}
public void setE_age(int e_age) {
this.e_age = e_age;
}
public String getE_address() {
return e_address;
}
public void setE_address(String e_address) {
this.e_address = e_address;
}
public Project getProject() {
return project;
}
public void setProject(Project project) {
this.project = project;
}
@Override
public String toString() {
return "Employee_table [e_name=" + e_name + "]";
}
}
Project class-
package com.vt.project.beans;
import java.util.*;
Document sign date :11 Jul, 2015
www.globsynskills.com 20
public class Project {
private int p_id;
private String p_name;
private String p_desc;
private int p_duration;
private String p_location;
public Project(){}
public Project(int p_id, String p_name, String p_desc, int p_duration,
String p_location) {
super();
this.p_id = p_id;
this.p_name = p_name;
this.p_desc = p_desc;
this.p_duration = p_duration;
this.p_location = p_location;
}
@Override
public String toString() {
return "Project_table [p_name=" + p_name + "]";
}
public int getP_id() {
return p_id;
}
public void setP_id(int p_id) {
this.p_id = p_id;
}
public String getP_name() {
return p_name;
}
public void setP_name(String p_name) {
this.p_name = p_name;
}
public String getP_desc() {
return p_desc;
}
public void setP_desc(String p_desc) {
this.p_desc = p_desc;
Document sign date :11 Jul, 2015
www.globsynskills.com 21
}
public int getP_duration() {
return p_duration;
}
public void setP_duration(int p_duration) {
this.p_duration = p_duration;
}
public String getP_location() {
return p_location;
}
public void setP_location(String p_location) {
this.p_location = p_location;
}
}
User Class-
package com.vt.project.beans;
public class User {
private int u_id;
private String u_name;
private String u_email;
private String u_password;
private String u_role;
public User(){}
public User(int u_id, String u_name, String u_email,
String u_password, String u_role) {
super();
this.u_id = u_id;
this.u_name = u_name;
this.u_email = u_email;
this.u_password = u_password;
this.u_role = u_role;
}
public int getU_id() {
return u_id;
}
Document sign date :11 Jul, 2015
www.globsynskills.com 22
public void setU_id(int u_id) {
this.u_id = u_id;
}
public String getU_name() {
return u_name;
}
public void setU_name(String u_name) {
this.u_name = u_name;
}
public String getU_email() {
return u_email;
}
public void setU_email(String u_email) {
this.u_email = u_email;
}
public String getU_password() {
return u_password;
}
public void setU_password(String u_password) {
this.u_password = u_password;
}
public String getU_role() {
return u_role;
}
public void setU_role(String u_role) {
this.u_role = u_role;
}
@Override
public String toString() {
return "user_table [u_name=" + u_name + "]";
}
}
Util classes:-
DBUtils class-
package com.vt.project.utils;
Document sign date :11 Jul, 2015
www.globsynskills.com 23
import java.sql.*;
public class DBUtils {
static Connection con = null;
static Statement st = null;
static PreparedStatement pst = null;
static ResultSet rs = null;
public static Connection getConnected(){
String user = "root";
String pass = "";
String url = "jdbc:mysql://localhost:3306/project_db";
try {
Class.forName("com.mysql.jdbc.Driver");
con = DriverManager.getConnection(url, user, pass);
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch(SQLException e){
e.printStackTrace();
}
return con;
}
public static Statement getStatement(){
try {
st=con.createStatement();
} catch (SQLException e) {
e.printStackTrace();
}
return st;
}
public static PreparedStatement getPreparedStatement(String sql){
try {
pst = con.prepareStatement(sql);
Document sign date :11 Jul, 2015
www.globsynskills.com 24
} catch (SQLException e) {
e.printStackTrace();
}
return pst;
}
public static void releaseResources(){
try{
if(rs != null)
rs.close();
if(pst != null)
pst.close();
if(st != null)
st.close();
if(con != null)
con.close();
}catch(SQLException e){
e.printStackTrace();
}
}
}
BDOUseutils interface-
package com.vt.project.utils;
import com.vt.project.beans.*;
import java.util.*;
public interface BDOUserutils {
public User login(String email,String password,String role);
public boolean registerProject(Project project);
public boolean removeproject(int p_id,String p_name);
Document sign date :11 Jul, 2015
www.globsynskills.com 25
public List<Project> viewAllProjects();
public Project detailOfProject(int p_id,String p_name);
public List<Employee> viewProjectEmployee(int p_id);
}
BDOUserutilsimpl class-
package com.vt.project.utils;
import java.sql.*;
import java.util.ArrayList;
import java.util.List;
import com.vt.project.utils.*;
import com.vt.project.beans.Employee;
import com.vt.project.beans.Project;
import com.vt.project.beans.User;
public class BDOUserutilsimpl implements BDOUserutils{
Connection con=null;
PreparedStatement pst=null;
ResultSet rs=null;
int result=0;
public User login(String email,String password,String role)
{
User user=null;
con=DBUtils.getConnected();
String sql="select * from user_table where u_email=? AND
u_password=? AND u_role=?";
pst=DBUtils.getPreparedStatement(sql);
try
{
pst.setString(1,email);
pst.setString(2, password);
pst.setString(3, role);
rs=pst.executeQuery();
if(rs!=null)
{
if(rs.next()){
Document sign date :11 Jul, 2015
www.globsynskills.com 26
user=new User();
user.setU_id(rs.getInt(1));
user.setU_name(rs.getString(2));
user.setU_email(rs.getString(3));
user.setU_password(rs.getString(4));
user.setU_role(rs.getString(5));
}
}
}
catch(SQLException e){
e.printStackTrace();
}
finally
{
DBUtils.releaseResources();
}
return user;
}
public boolean registerProject(Project project)
{
boolean isRegistered = false;
con = DBUtils.getConnected();
String sql = "insert into project_table
(p_id,p_name,p_desc,p_location,p_duration) values (?,?,?,?,?)";
pst = DBUtils.getPreparedStatement(sql);
try{
pst.setInt(1, project.getP_id());
pst.setString(2, project.getP_name());
pst.setString(3, project.getP_desc());
pst.setString(4, project.getP_location());
pst.setInt(5, project.getP_duration());
result = pst.executeUpdate();
}catch(SQLException e){
e.printStackTrace();
}finally{
DBUtils.releaseResources();
}
if(result >0)
Document sign date :11 Jul, 2015
www.globsynskills.com 27
isRegistered = true;
return isRegistered;
}
public List<Project> viewAllProjects()
{
List<Project> plist= new ArrayList<Project>();
con = DBUtils.getConnected();
String sql = "select * from project_table";
pst = DBUtils.getPreparedStatement(sql);
try{
rs = pst.executeQuery();
if(rs!=null){
while(rs.next()){
Project project = new Project();
project.setP_id(rs.getInt(1));
project.setP_name(rs.getString(2));
project.setP_desc(rs.getString(3));
project.setP_duration(rs.getInt(5));
project.setP_location(rs.getString(4));
plist.add(project);
}
}
}catch(SQLException e){
e.printStackTrace();
}
return plist;
}
public Project detailOfProject(int p_id,String p_name){
Project project = null;
con = DBUtils.getConnected();
String sql = "select * from project_table where p_id=? AND
p_name=?";
pst = DBUtils.getPreparedStatement(sql);
try{
pst.setInt(1, p_id);
pst.setString(2, p_name);
Document sign date :11 Jul, 2015
www.globsynskills.com 28
rs = pst.executeQuery();
if(rs != null){
while(rs.next()){
project = new Project();
project.setP_id(rs.getInt(1));
project.setP_name(rs.getString(2));
project.setP_desc(rs.getString(3));
project.setP_duration(rs.getInt(5));
project.setP_location(rs.getString(4));
}
}
} catch (SQLException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
DBUtils.releaseResources();
return project;
}
public List<Employee> viewProjectEmployee(int p_id){
List<Employee> empList = new ArrayList<Employee>();
Employee emp = null;
con = DBUtils.getConnected();
String sql = "select * from Employee_table where p_id=?";
pst = DBUtils.getPreparedStatement(sql);
try {
pst.setInt(1,p_id );
rs = pst.executeQuery();
if(rs != null){
while(rs.next()){
emp = new Employee();
emp.setE_id(rs.getInt(1));
emp.setE_name(rs.getString(2));
emp.setE_age(rs.getInt(3));
emp.setE_address(rs.getString(4));
emp.setE_contact(rs.getLong(6));
empList.add(emp);
}
}
Document sign date :11 Jul, 2015
www.globsynskills.com 29
} catch (SQLException e) {
e.printStackTrace();
}
DBUtils.releaseResources();
return empList;
}
public boolean removeproject(int p_id,String p_name)
{
con = DBUtils.getConnected();
int res=0;
boolean isremoved=false;
String sql = "delete from project_table where p_id=? AND
p_name=?";
pst = DBUtils.getPreparedStatement(sql);
try {
pst.setInt(1,p_id );
pst.setString(2,p_name);
res = pst.executeUpdate();
}
catch(SQLException e){
e.printStackTrace();
}finally{
DBUtils.releaseResources();
}
if(res >0)
isremoved= true;
else
System.out.println("Deletion not possible");
return isremoved;
}
}
GPUserutils interface-
package com.vt.project.utils;
import java.util.*;
import com.vt.project.beans.*;
Document sign date :11 Jul, 2015
www.globsynskills.com 30
public interface GPUserutils {
public User login(String email,String password,String role);
public boolean logout(User user);
public boolean registerEmployee(Employee emp);
public List<Employee> viewAllEmployee();
public Employee detailOfEmployee(int e_id,String e_name);
}
GPUserutilsimpl class-
package com.vt.project.utils;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.*;
import com.vt.project.utils.*;
import com.vt.project.beans.*;
public class GPUserutilsimpl implements GPUserutils {
Connection con = null;
PreparedStatement pst = null;
ResultSet rs = null;
int result = 0;
public User login(String email, String password, String role) {
User user = null;
con = DBUtils.getConnected();
String sql = "select * from user_table where u_email=?
AND u_password=? AND u_role=?";
pst = DBUtils.getPreparedStatement(sql);
try {
pst.setString(1, email);
pst.setString(2, password);
pst.setString(3, role);
rs = pst.executeQuery();
if (rs != null) {
if (rs.next()) {
user = new User();
user.setU_id(rs.getInt(1));
user.setU_name(rs.getString(2));
user.setU_email(rs.getString(3));
Document sign date :11 Jul, 2015
www.globsynskills.com 31
user.setU_password(rs.getString(4));
user.setU_role(rs.getString(5));
}
}
} catch (SQLException e) {
e.printStackTrace();
}
finally {
DBUtils.releaseResources();
}
return user;
}
public boolean logout(User user) {
return false;
}
public boolean registerEmployee(Employee emp) {
boolean isRegistered = false;
con = DBUtils.getConnected();
String sql = "insert into Employee_table
(e_name,e_age,e_address,p_id,e_contact) values (?,?,?,?,?)";
pst = DBUtils.getPreparedStatement(sql);
int result = 0;
try {
// pst.setInt(1, e.getE_id());
pst.setString(1, emp.getE_name());
pst.setInt(2, emp.getE_age());
pst.setString(3, emp.getE_address());
pst.setInt(4, emp.getProject().getP_id());
pst.setLong(5, emp.getE_contact());
result = pst.executeUpdate();
} catch (SQLException e) {
e.printStackTrace();
} finally {
DBUtils.releaseResources();
}
if (result > 0) {
isRegistered = true;
Document sign date :11 Jul, 2015
www.globsynskills.com 32
}
return isRegistered;
}
public List<Employee> viewAllEmployee() {
List<Employee> empList = new ArrayList<Employee>();
con = DBUtils.getConnected();
String sql = "select * from Employee_table";
pst = DBUtils.getPreparedStatement(sql);
try {
rs = pst.executeQuery();
if (rs != null) {
while (rs.next()) {
Employee emp = new Employee();
emp.setE_id(rs.getInt(1));
emp.setE_name(rs.getString(2));
emp.setE_age(rs.getInt(3));
emp.setE_address(rs.getString(4));
Project p = new Project();
p.setP_id(rs.getInt(5));
emp.setProject(p);
emp.setE_contact(rs.getLong(6));
empList.add(emp);
}
}
} catch (SQLException e) {
e.printStackTrace();
}
DBUtils.releaseResources();
return empList;
}
public Employee detailOfEmployee(int e_id, String e_name) {
Employee emp = null;
con = DBUtils.getConnected();
String sql = "select * from employee_table where e_id=?
AND e_name=?";
pst = DBUtils.getPreparedStatement(sql);
try {
Document sign date :11 Jul, 2015
www.globsynskills.com 33
pst.setInt(1, e_id);
pst.setString(2, e_name);
rs = pst.executeQuery();
if (rs != null) {
while (rs.next()) {
emp = new Employee();
emp.setE_id(rs.getInt(1));
emp.setE_name(rs.getString(2));
emp.setE_age(rs.getInt(3));
emp.setE_address(rs.getString(4));
emp.setE_contact(rs.getLong(6));
}
}
} catch (SQLException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
DBUtils.releaseResources();
return emp;
}
}
Code for Login:-
package com.vt.project.servlet;
import java.io.IOException;
import com.vt.project.*;
import com.vt.project.utils.*;
import com.vt.project.beans.*;
import javax.servlet.*;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
/**
* Servlet implementation class Loginservlet
*/
Document sign date :11 Jul, 2015
www.globsynskills.com 34
@WebServlet("/Loginservlet")
public class Loginservlet extends HttpServlet {
public void doGet(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
String email = request.getParameter("mail");
String password = request.getParameter("upass");
String role = request.getParameter("loginAs");
if(role.equals("BDO"))
{
BDOUserutilsimpl u = new BDOUserutilsimpl();
User user = u.login(email, password, role);
if(user != null){
HttpSession session =
request.getSession(true);
session.setAttribute("user", user);
RequestDispatcher rd =
request.getRequestDispatcher("BDOHome.jsp");
rd.forward(request, response);
}else{
request.setAttribute("valid", "false");
RequestDispatcher rd =
request.getRequestDispatcher("Home.jsp");
rd.forward(request, response);
}
}else if(role.equals("GP")){
GPUserutilsimpl gp=new GPUserutilsimpl();
User user=gp.login(email, password, role);
if(user != null){
HttpSession session =
request.getSession(true);
session.setAttribute("user", user);
RequestDispatcher rd =
request.getRequestDispatcher("GPHome.jsp");
rd.forward(request, response);
}else{
request.setAttribute("valid", "false");
Document sign date :11 Jul, 2015
www.globsynskills.com 35
RequestDispatcher rd =
request.getRequestDispatcher("Home.jsp");
rd.forward(request, response);
}
}
}
public void doPost(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
doGet(request,response);
}
}
Login JSP :-
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body bgcolor='khaki'>
<img src="HomeHeaderImage.jpg.gif" align="top" width="100%">
<center>
<h2 style="font-family:Bradley Hand
ITC;color:blue;"><u>The Mahatma Gandhi Rural Employement Gurantee
Act</u></h2>
</center>
<hr width="100%" color="red">
<center><p style="font-family:Viner Hand ITC;color:brown;">Please
login to continue...</p></center>
<form method="POST" action="Loginservlet">
<table border="1" align="center">
<tr>
<td>Email ID :</td>
Document sign date :11 Jul, 2015
www.globsynskills.com 36
<td><input type="text" name="mail"></td>
</tr>
<tr>
<td>Password :</td>
<td><input type="password" name="upass"></td>
</tr>
<tr>
<td>Login As :</td>
<td><select name="loginAs">
<option value="">Select</option>
<option value="BDO">BDO</option>
<option
value="GP">GRAMPANCHAYET</option>
</select></td>
</tr>
<tr>
<td colspan="2" align="right"><input
type="submit"
value="Login" name="sub"></td>
</tr>
<%
String valid = (String)
request.getAttribute("valid");
if (valid != null) {
if (valid.equals("false")) {
%>
<tr>
<td colspan="2">Please check email, password
OR role...!</td>
</tr>
<%
}
}
%>
</table>
</form>
</body>
</html>
Document sign date :11 Jul, 2015
www.globsynskills.com 37
BDOHome.jsp-
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-
8859-1">
<title><b>Welcome</b></title>
</head>
<body bgcolor="NavajoWhite" >
<img src="NREGA.jpg" align="top" width=100%>
<h2 style="font-family:Cooper Black;color:chocolate;"><u>
WELCOME </u></h2>
<ul type="square">
<li><a href="AddProject.jsp"> Add a new project</br></a></li>
<li><a href="ListofProject">View all registered
projects</br></a></li>
<li><a href="projectform.jsp">View details of a
project</br></a></li>
<li><a href="ProjectEmployees.jsp">View list of employees in a
project</br></a></li>
<li><a href="RemoveProject.jsp">Delete a project</br></a></li>
<li><a href="Tologout.jsp">LOGOUT</a></li>
</ul>
</body>
</html>
GPHome.jsp-
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-
8859-1">
Document sign date :11 Jul, 2015
www.globsynskills.com 38
<title>Welcome</title>
</head>
<body bgcolor="NavajoWhite" >
<img src="NREGA.jpg" align="top" width="100%">
<
<h2 style="font-family:Cooper Black;color:chocolate;"><u>
WELCOME </u></h2>
<ul type="square">
<body bgcolor="aquamarine">
<li><a href="Addemployee"> Add a new employee and assign a
project</br></a></li>
<li><a href="ListofEmployee">View all registered
employees</br></a></li>
<li><a href="empdetailform.jsp">View employee details</br></a></li>
<li><a href="Tologout.jsp">BACK</a></li>
</body>
</html>
Code for Project Registration:-
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<%@
page import="com.vt.project.beans.*"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>AddProject</title>
</head>
<body background="big1.jpg" >
<img src="MGNREGA_Logo.gif" align="left" height="550" width="50%">
<div style="text-align:right">
Document sign date :11 Jul, 2015
www.globsynskills.com 39
<h2 style="font-family:Cooper Black;color:purple;"><u>FILL UP
PROJECT DETAILS </u></h2>
<ul type="square">
<form method="POST" action="Addproject1">
<table border="0" align="center">
<%
String status = (String)
request.getAttribute("added");
%>
<%
if (status != null && status.equals("yes")) {
%>
<tr>
<td colspan="2">Project Added
Successfully..!</td>
</tr>
<%
} else if (status != null &&
status.equals("no")) {
%>
<tr>
<td colspan="2">Operation Failed..!</td>
</tr>
<%
}
%>
<tr>
<td>Project ID :</td>
<td><input type="text" name="ID"></td>
</tr>
<tr>
<td>Project name :</td>
<td><input type="text" name="name"></td>
</tr>
<tr>
<td>Descrption :</td>
<td><input type="text"
name="description"></td>
Document sign date :11 Jul, 2015
www.globsynskills.com 40
</tr>
<tr>
<td>Location :</td>
<td><input type="text" name="location"></td>
</tr>
<tr>
<td>Duration :</td>
<td><input type="value" name="duration"></td>
</tr>
<tr>
<td colspan="2" align="center"><input
type="submit"
value="Submit" name="sub"></td>
</tr>
</table>
</form>
<a href="BDOHome.jsp">Back to Home</a>
</ul>
</div>
</body>
</html>
Servlet:-
package com.vt.project.servlet;
import com.vt.project.beans.*;
import com.vt.project.utils.*;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
Document sign date :11 Jul, 2015
www.globsynskills.com 41
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
/**
* Servlet implementation class addproject1
*/
@WebServlet("/Addproject1")
public class Addproject1 extends HttpServlet {
protected void doGet(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
}
protected void doPost(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
int id=Integer.parseInt(request.getParameter("ID"));
String name=request.getParameter("name");
String descrip=request.getParameter("description");
String location=request.getParameter("location");
int
duration=Integer.parseInt(request.getParameter("duration"));
boolean a=false;
Project pro=new Project();
pro.setP_id(id);
pro.setP_name(name);
pro.setP_desc(descrip);
pro.setP_location(location);
pro.setP_duration(duration);
BDOUserutilsimpl u=new BDOUserutilsimpl();
a=u.registerProject(pro);
if(a){
request.setAttribute("added", "yes");
RequestDispatcher rd =
request.getRequestDispatcher("AddProject.jsp");
rd.forward(request, response);
}else{
request.setAttribute("added", "no");
Document sign date :11 Jul, 2015
www.globsynskills.com 42
RequestDispatcher rd =
request.getRequestDispatcher("AddProject.jsp");
rd.forward(request, response);
}
}
}
Code for List of project:-
package com.vt.project.servlet;
import java.io.IOException;
import java.util.List;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.vt.project.beans.*;
import com.vt.project.utils.*;
@WebServlet("/ListofProject")
public class ListofProject extends HttpServlet {
protected void doGet(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
BDOUserutilsimpl u = new BDOUserutilsimpl();
List<Project> projects = u.viewAllProjects();
request.setAttribute("projectList", projects);
RequestDispatcher rd =
request.getRequestDispatcher("Projectlist.jsp");
rd.forward(request, response);
}
protected void doPost(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
doGet(request,response);
}
}
Projectlist.jsp:-
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
Document sign date :11 Jul, 2015
www.globsynskills.com 43
pageEncoding="ISO-8859-1"%>
<%@page import="java.util.*,com.vt.project.beans.*"
import ="com.vt.project.utils.*"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-
8859-1">
<title>Insert title here</title>
</head>
<body background="big1.jpg" >
<img src="MGNREGA_Logo.gif" align="left" height="550" width="50%">
<div style="text-align:right">
<h2 style="font-family:Cooper Black;color:purple;"><u>LIST OF
PROJECTS </u></h2>
<%
List<Project> projects =
(List<Project>)request.getAttribute("projectList");
%>
<table align="center" border="1">
<tr>
<th>Name</th>
<th>Id</th>
<th>Description</th>
<th>Location</th>
<th>Duration</th>
<th></th>
</tr>
<%
if (projects!= null) {
for (Project pt:projects) {
%>
<tr>
<td><%=pt.getP_name()%></td>
<td><%=pt.getP_id()%></td>
<td><%=pt.getP_desc()%></td>
Document sign date :11 Jul, 2015
www.globsynskills.com 44
<td><%=pt.getP_location()%></td>
<td><%=pt.getP_duration()%></td>
</tr>
<%
}
projects = null;
} else {
%>
<tr>
<td colspan="5" align="center"> No projects Found..!
</td>
</tr>
<%
%>
</table>
<center><a href="BDOHome.jsp">GO TO HOME
PAGE</a></center>
</div>
</body>
</html>
Code for detail of a particular project:-
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-
8859-1">
<title>Insert title here</title>
</head>
<body background="big1.jpg" >
<img src="MGNREGA_Logo.gif" align="left" height="550" width="50%">
<div style="text-align:right">
Document sign date :11 Jul, 2015
www.globsynskills.com 45
<h2 style="font-family:Cooper
Black;color:purple;"><u>PLEASE ENTER REQUIRED DATA </u></h2>
<form method="POST" action="Prodetail">
<table border="0" align="center">
<tr>
<td>Project ID :</td>
<td><input type="value" name="ID"></td>
</tr>
<tr>
<td>Project name :</td>
<td><input type="text" name="name"></td>
</tr>
<tr>
<td colspan="2" align="center"><input
type="submit"
value="Submit" name="sub"></td>
</tr>
</table>
</form>
</div>
</body>
</html>
Servlet:-
package com.vt.project.servlet;
import java.io.IOException;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.vt.project.*;
import com.vt.project.beans.Project;
import com.vt.project.servlet.*;
import com.vt.project.utils.*;
Document sign date :11 Jul, 2015
www.globsynskills.com 46
@WebServlet("/Prodetail")
public class Prodetail extends HttpServlet {
protected void doGet(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
int p_id = Integer.parseInt(request.getParameter("ID"));
String p_name=request.getParameter("name");
BDOUserutilsimpl u = new BDOUserutilsimpl();
Project projects = u.detailOfProject(p_id,p_name);
request.setAttribute("projectDetails", projects);
RequestDispatcher rd =
request.getRequestDispatcher("ProjectinDetail.jsp");
rd.forward(request, response);
}
protected void doPost(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
doGet(request, response);
}
}
Projectindetail.jsp:-
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<%@page import="com.vt.project.beans.*"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body background="big1.jpg" >
<img src="MGNREGA_Logo.gif" align="left" height="550" width="50%">
<div style="text-align:right">
<h2 style="font-family:Cooper Black;color:purple;"><u>PROJECT
DETAIL </u></h2>
<%
Document sign date :11 Jul, 2015
www.globsynskills.com 47
Project pro = (Project)request.getAttribute("projectDetails");
%>
<table border="1" align="center">
<tr>
<td colspan="2"><b>Project Details</b></td>
</tr>
<tr>
<td>Id :</td><td><%=pro.getP_id() %></td>
</tr>
<tr>
<td>Name :</td><td><%=pro.getP_name() %></td>
</tr>
<tr>
<td>Description :</td><td><%=pro.getP_desc() %></td>
</tr>
<tr>
<td>Location :</td><td><%=pro.getP_location() %></td>
</tr>
<tr>
<td>Duration :</td><td><%=pro.getP_duration() %></td>
</tr>
</table>
<a href="BDOHome.jsp">Home Page</a>||<a href="projectform.jsp">Back
Page</a>
</div>
</body>
</html>
Code for list of employee in a particular project:-
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-
8859-1">
Document sign date :11 Jul, 2015
www.globsynskills.com 48
<title>Insert title here</title>
</head>
<body background="big1.jpg" >
<img src="MGNREGA_Logo.gif" align="left" height="550" width="50%">
<div style="text-align:right">
<h2 style="font-family:Cooper Black;color:purple;"><u>PLEASE
ENTER REQUIRED DATA </u></h2>
<form method="POST" action="Projectemp">
<table border="0" align="center">
<tr>
<td>Project ID :</td>
<td><input type="value" name="p_id"></td>
</tr>
<tr>
<td colspan="2" align="center"><input type="submit"
value="Submit" name="sub"></td>
</tr>
</table></form>
</div>
</body>
</html>
Servlet:-
package com.vt.project.servlet;
import com.vt.project.beans.*;
import com.vt.project.utils.*;
import java.io.IOException;
import java.util.List;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
Document sign date :11 Jul, 2015
www.globsynskills.com 49
* Servlet implementation class projectemp
*/
@WebServlet("/Projectemp")
public class Projectemp extends HttpServlet {
protected void doGet(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
int p_id =
Integer.parseInt(request.getParameter("id"));
BDOUserutils u = new BDOUserutilsimpl();
List<Employee> emp=
u.viewProjectEmployee(p_id);
request.setAttribute("emp", emp);
RequestDispatcher rd =
request.getRequestDispatcher("projectemp1.jsp");
rd.forward(request, response);
}
protected void doPost(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
doGet(request, response);
}
}
Projectemp1.jsp:-
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<%@page import="com.vt.project.beans.*"
import="java.util.*"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
Document sign date :11 Jul, 2015
www.globsynskills.com 50
<body background="big1.jpg" >
<img src="MGNREGA_Logo.gif" align="left" height="550" width="50%">
<div style="text-align:right">
<h2 style="font-family:Cooper Black;color:purple;"><u>EMPLOYEE
DETAIL</u></h2>
<%
List<Employee> emp = (List<Employee>)request.getAttribute("emp");
%>
<table align="center" border="1">
<tr>
<th>ID</th>
<th>NAME</th>
<th>AGE</th>
<th>ADDRESS</th>
<th>CONTACT NO</th>
</tr>
<%
if (emp!= null) {
for (Employee e:emp) {
%>
<tr>
<td><%=e.getE_id()%></td>
<td><%=e.getE_name()%></td>
<td><%=e.getE_age()%></td>
<td><%=e.getE_address()%></td>
<td><%=e.getE_contact()%></td>
</tr>
<%
}
emp = null;
} else {
%>
<tr>
<td colspan="5" align="center"> opertion failed!
</td>
</tr>
<%
}
Document sign date :11 Jul, 2015
www.globsynskills.com 51
%>
</table>
<a href="BDOHome.jsp">Home Page</a>
</div>
</body>
</html>
Code for removing a project:-
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-
8859-1">
<title>Insert title here</title>
</head>
<body background="big1.jpg" >
<img src="MGNREGA_Logo.gif" align="left" height="550" width="50%">
<div style="text-align:right">
<form method="POST" action="Remove">
<table border="0" align="center">
<tr>
<td>Project ID :</td>
<td><input type="text" name="ID"></td>
</tr>
<tr>
<td>Project name :</td>
<td><input type="text" name="name"></td>
</tr>
<tr><td><input type="submit"
name="remove"></td></tr>
</table>
</form>
</div>
Document sign date :11 Jul, 2015
www.globsynskills.com 52
</body>
</html>
Servlet:-
package com.vt.project.servlet;
import java.io.IOException;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.vt.project.utils.BDOUserutilsimpl;
/**
* Servlet implementation class remove
*/
@WebServlet("/Remove")
public class Remove extends HttpServlet {
protected void doGet(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
boolean a=false;
int id=Integer.parseInt(request.getParameter("ID"));
String name=request.getParameter("name");
BDOUserutilsimpl u=new BDOUserutilsimpl();
a=u.removeproject(id,name);
if(a){
request.setAttribute("removed", "yes");
RequestDispatcher rd =
request.getRequestDispatcher("remove1.jsp");
rd.forward(request, response);
}else{
request.setAttribute("removed", "no");
RequestDispatcher rd =
request.getRequestDispatcher("remove1.jsp");
rd.forward(request, response);
}
}
/**
Document sign date :11 Jul, 2015
www.globsynskills.com 53
* @see HttpServlet#doPost(HttpServletRequest request,
HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
doGet(request,response);
}
}
remove1.jsp:-
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<%@page import="com.vt.project.utils.*"
import="com.vt.project.beans.*"
import="java.sql.*"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-
8859-1">
<title>Insert title here</title>
</head>
<body background="big1.jpg" >
<img src="MGNREGA_Logo.gif" align="left" height="550" width="50%">
<div style="text-align:right">
<h2 style="font-family:Cooper Black;color:purple;"><u>
</u></h2>
<%
String a = (String)
request.getAttribute("removed");
%>
<%
if (a != null && a.equals("yes")) {
%>
<tr>
Document sign date :11 Jul, 2015
www.globsynskills.com 54
<td colspan="2">Project removed
Successfully..!</td>
</tr>
<%
} else if (a != null && a.equals("no")) {
%>
<tr>
<td colspan="2">EMPLOYEES ARE ENGAGED IN THIS
PROCESS</BR>SORRY!!CANNOT BE DELETED</td>
</tr>
<%
}
%>
<a href="ListofProject">List of updated projects></a>
</div>
</body>
</html>
Code for registering employee by GP:-
Servlet:
package com.vt.project.servlet;
import java.io.IOException;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.util.List;
import com.vt.project.beans.Project;
import com.vt.project.utils.BDOUserutils;
import com.vt.project.utils.BDOUserutilsimpl;
/**
* Servlet implementation class AddEmployeePreparerServlet
*/
@WebServlet("/Addemployee")
Document sign date :11 Jul, 2015
www.globsynskills.com 55
public class AddEmployeePreparerServlet extends HttpServlet {
protected void doGet(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
BDOUserutils u = new BDOUserutilsimpl();
List<Project> pList = u.viewAllProjects();
HttpSession session = request.getSession(false);
session.setAttribute("projects", pList);
RequestDispatcher rd =
request.getRequestDispatcher("Addemployee.jsp");
rd.forward(request, response);
}
}
Servlet:-
package com.vt.project.servlet;
import java.io.IOException;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.vt.project.beans.Employee;
import com.vt.project.beans.Project;
import com.vt.project.utils.BDOUserutilsimpl;
import com.vt.project.utils.GPUserutilsimpl;
/**
* Servlet implementation class AddEmployee
*/
@WebServlet("/AddEmployee")
public class AddEmployee extends HttpServlet {
protected void doGet(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
}
Document sign date :11 Jul, 2015
www.globsynskills.com 56
/**
* @see HttpServlet#doPost(HttpServletRequest request,
HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
String name=request.getParameter("name");
int age=Integer.parseInt(request.getParameter("age"));
String address=request.getParameter("address");
int pid=Integer.parseInt(request.getParameter("PID"));
long
contact=Long.parseLong(request.getParameter("contact"));
boolean a=false;
Employee e=new Employee();
e.setE_name(name);
e.setE_age(age);
e.setE_address(address);
Project p=new Project();
p.setP_id(pid);
e.setProject(p);
e.setE_contact(contact);
GPUserutilsimpl u=new GPUserutilsimpl();
a=u.registerEmployee(e);
if(a){
request.setAttribute("added", "yes");
RequestDispatcher rd =
request.getRequestDispatcher("Addemployee.jsp");
rd.forward(request, response);
}else{
request.setAttribute("added", "no");
RequestDispatcher rd =
request.getRequestDispatcher("Addemployee.jsp");
rd.forward(request, response);
}
}
}
Document sign date :11 Jul, 2015
www.globsynskills.com 57
Addemployee.jsp:-
<%@page import="com.vt.project.beans.Project"%>
<%@page import="java.util.*"%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-
8859-1">
<title><b>EMPLOYEE REGISTRATION</b></title>
</head>
<body background="big1.jpg" >
<img src="MGNREGA_Logo.gif" align="left" height="550" width="50%">
<div style="text-align:right">
<h2 style="font-family:Cooper Black;color:purple;"><u>Enter
Employee Details</u></h2>
<%
List<Project> plist =
(List<Project>)session.getAttribute("projects");
%>
<center>
<h2></h2>
</center>
<form method="POST" action="AddEmployee">
<table border="0" align="right" WIDTH="50%" HEIGHT="250"
>
<%
String status = (String)
request.getAttribute("added");
%>
<%
if (status != null && status.equals("yes")) {
%>
Document sign date :11 Jul, 2015
www.globsynskills.com 58
<tr>
<td colspan="5">Employee Added
Successfully..!</td>
</tr>
<%
} else if (status != null &&
status.equals("no")) {
%>
<tr>
<td colspan="5">Operation Failed..!</td>
</tr>
<%
}
%>
<tr>
<td colspan="5"><font color=black
face="geneva,arial"size=3>Employee name :</font></td>
<td><input type="text" name="name"></td>
</tr>
<tr>
<td colspan="5"><font color=black
face="geneva,arial"size=3>Age :</font></td>
<td><input type="value" name="age"></td>
</tr>
<tr>
<td colspan="5"><font color=black
face="geneva,arial"size=3>Address :</font></td>
<td><input type="text" name="address"></td>
</tr>
<tr>
<td colspan="5"><font color=black
face="geneva,arial"size=3>Select Project :</font></td>
<td><select name="PID">
<%
Document sign date :11 Jul, 2015
www.globsynskills.com 59
for(Project p : plist){
%>
<option
value="<%=p.getP_id()%>"><%=p.getP_name() %></option>
<%} %>
</select></td>
</tr>
<tr>
<td colspan="5"><font color=black
face="geneva,arial"size=3>Contact :</font></td>
<td><input type="text" name="contact"></td>
</tr>
<tr>
<td colspan="2" align="center"><input
type="submit"
value="Register Employee"
name="sub"></td>
</tr>
</table>
</form>
<a href="GPHome.jsp">Back</a>
</div>
</body>
</html>
Code for list of employee:-
package com.vt.project.servlet;
import java.io.IOException;
import java.util.List;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
Document sign date :11 Jul, 2015
www.globsynskills.com 60
import javax.servlet.http.HttpServletResponse;
import com.vt.project.beans.Employee;
import com.vt.project.beans.Project;
import com.vt.project.utils.BDOUserutilsimpl;
import com.vt.project.utils.GPUserutilsimpl;
/**
* Servlet implementation class ListofEmployee
*/
@WebServlet("/ListofEmployee")
public class ListofEmployee extends HttpServlet {
/**
* @see HttpServlet#doGet(HttpServletRequest request,
HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
GPUserutilsimpl u = new GPUserutilsimpl();
List<Employee> emps = u.viewAllEmployee();
request.setAttribute("EmployeeList", emps);
RequestDispatcher rd =
request.getRequestDispatcher("ListofEmployee.jsp");
rd.forward(request, response);
}
/**
* @see HttpServlet#doPost(HttpServletRequest request,
HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
doGet(request,response);
}
}
ListofEmployee.jsp:-
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
Document sign date :11 Jul, 2015
www.globsynskills.com 61
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<%@ page import="com.vt.project.utils.*"
import="java.util.*"
import="com.vt.project.beans.*"
import="java.sql.*" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-
8859-1">
<title>List of all employees</title>
</head>
<body background="big1.jpg" >
<img src="MGNREGA_Logo.gif" align="left" height="550" width="50%">
<div style="text-align:right">
<%
List<Employee> e = (List<Employee>)
request.getAttribute("EmployeeList");
%>
<h2 style="font-family:Cooper Black;color:purple;"><u>LIST OF
EMPLOYEE </u></h2>
<table align="center" border="1">
<tr>
<th>ID</th>
<th>Name</th>
<th>Age</th>
<th>Address</th>
<th>Project ID</th>
<th>Contact</th>
</tr>
<%
if (e!= null) {
for (Employee emp:e) {
%>
<tr>
<td><%=emp.getE_id()%></td>
<td><%=emp.getE_name()%></td>
Document sign date :11 Jul, 2015
www.globsynskills.com 62
<td><%=emp.getE_age()%></td>
<td><%=emp.getE_address()%></td>
<td><%=emp.getProject().getP_id()%></td>
<td><%=emp.getE_contact()%></td>
</tr>
<%
}
e = null;
} else {
%>
<tr>
<td colspan="5" align="center"> No employees
Found..! </td>
</tr>
<%
}
%>
</table>
<a href="GPHome.jsp">BACK</a>
</div>
</body>
</html>
Code for detail of a particular employee:-
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-
8859-1">
<title>Insert title here</title>
</head>
<body background="big1.jpg" >
<img src="MGNREGA_Logo.gif" align="left" height="550" width="50%">
<div style="text-align:right">
<h2 style="font-family:Cooper Black;color:purple;"><u>PLEASE
ENTER REQUIRED DATA </u></h2>
Document sign date :11 Jul, 2015
www.globsynskills.com 63
<form method="POST" action="Empdetail">
<table border="0" align="center">
<tr>
<td>Employee ID :</td>
<td><input type="value" name="ID"></td>
</tr>
<tr>
<td>Employee name :</td>
<td><input type="text" name="name"></td>
</tr>
<tr>
<td colspan="2" align="center"><input
type="submit"
value="Submit" name="sub"></td>
</tr>
</table>
</form>
</div>
</body>
</html>
Servlet:-
package com.vt.project.servlet;
import java.io.IOException;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.vt.project.beans.Employee;
import com.vt.project.beans.Project;
import com.vt.project.utils.BDOUserutilsimpl;
import com.vt.project.utils.GPUserutilsimpl;
/**
* Servlet implementation class Empdetail
*/
Document sign date :11 Jul, 2015
www.globsynskills.com 64
@WebServlet("/Empdetail")
public class Empdetail extends HttpServlet {
protected void doGet(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
int e_id = Integer.parseInt(request.getParameter("ID"));
String e_name=request.getParameter("name");
GPUserutilsimpl u = new GPUserutilsimpl();
Employee emp = u.detailOfEmployee(e_id,e_name);
request.setAttribute("employeeDetails", emp);
RequestDispatcher rd =
request.getRequestDispatcher("empdetail.jsp");
rd.forward(request, response);
}
protected void doPost(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
doGet(request,response);
}
}
empdetail.jsp:-
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ page import="com.vt.project.beans.*" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-
8859-1">
<title>Insert title here</title>
</head>
<body background="big1.jpg" >
<img src="MGNREGA_Logo.gif" align="left" height="550" width="50%">
<div style="text-align:right">
Document sign date :11 Jul, 2015
www.globsynskills.com 65
<h2 style="font-family:Cooper Black;color:purple;"><u>EMPLOYEE
DETAILS </u></h2>
<%
Employee emp =
(Employee)request.getAttribute("employeeDetails");
%>
<center><h2>Employee Details Page</h2></center>
<table border="1" align="center">
<tr>
<td colspan="2"><b>Project Details</b></td>
</tr>
<tr>
<td>Id :</td><td><%=emp.getE_id() %></td>
</tr>
<tr>
<td>Name :</td><td><%=emp.getE_name() %></td>
</tr>
<tr>
<td>Age :</td><td><%=emp.getE_age() %></td>
</tr>
<tr>
<td>Address :</td><td><%=emp.getE_address() %></td>
</tr>
<tr>
<td>Contact:</td><td><%=emp.getE_contact() %></td>
</tr>
</table>
<a href="GPHome.jsp">Home Page</a>
</div>
</body>
</html>
Code for logout:-
Servlet:-
package com.vt.project.servlet;
Document sign date :11 Jul, 2015
www.globsynskills.com 66
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
/**
* Servlet implementation class Logout
*/
@WebServlet("/Logout")
public class Logout extends HttpServlet {
private static final long serialVersionUID = 1L;
/**
* @see HttpServlet#HttpServlet()
*/
public logout() {
super();
// TODO Auto-generated constructor stub
}
/**
* @see HttpServlet#doGet(HttpServletRequest request,
HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
HttpSession session = request.getSession(false);
session.invalidate();
response.setContentType("text/html");
RequestDispatcher
rd=request.getRequestDispatcher("Tologout.jsp");
}
}
Tologout.jsp:-
Document sign date :11 Jul, 2015
www.globsynskills.com 67
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ page import="javax.servlet.*"
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-
8859-1">
<title>Insert title here</title>
</head>
<body background="big1.jpg" >
<img src="MGNREGA_Logo.gif" align="left" height="550" width="50%">
<div style="text-align:right">
<h1><font color="MidnightBlue">You are Sucessfully logged
out...</font></h1>
<a href="Home.jsp">Go-Back To Home Page</a>
</form>
</div>
</body>
</html>
Document sign date :11 Jul, 2015
www.globsynskills.com 68
Certificate
This is to certify that Ms. MANISHA AGARWAL of Jalpaiguri Govt. Engg. College, registration
number:131010110092, has successfully completed a project on M.N.R.E.G.A. PORTAL using
JEE under the guidance of Mr. Bhavesh.
--- ---------------------------------------------------
-
Bhavesh
Globsyn Finishing School
(a division of Globsyn Skills)
Document sign date :11 Jul, 2015
www.globsynskills.com 69
Certificate
This is to certify that Ms. ANWESHA BHOWMIK of Jalpaiguri Govt. Engg. College, registration
number:131010110068, has successfully completed a project on M.N.R.E.G.A. PORTAL using
JEE under the guidance of Mr. Bhavesh.
--- ---------------------------------------------------
-
Bhavesh
Globsyn Finishing School
(a division of Globsyn Skills)
Document sign date :11 Jul, 2015
www.globsynskills.com 70
Certificate
This is to certify that Mr. ATANU DEB of Jalpaiguri Govt. Engg. College, registration
number:131010110073, has successfully completed a project on M.N.R.E.G.A. PORTAL using
JEE under the guidance of Mr. Bhavesh.
--- ---------------------------------------------------
-
Bhavesh
Globsyn Finishing School
(a division of Globsyn Skills)
Document sign date :11 Jul, 2015
www.globsynskills.com 71
Certificate
This is to certify that Ms. KRITI PAL of Jalpaiguri Govt. Engg. College, registration
number:131010110016, has successfully completed a project on M.N.R.E.G.A. PORTAL using
JEE under the guidance of Mr. Bhavesh.
--- ---------------------------------------------------
Bhavesh
Globsyn Finishing School
(a division of Globsyn Skills)
Document sign date :11 Jul, 2015
www.globsynskills.com 72
Certificate
This is to certify that Ms. MADHUMITA DAS of Jalpaiguri Govt. Engg. College, registration
number:131010110018, has successfully completed a project on M.N.R.E.G.A. PORTAL using
JEE under the guidance of Mr. Bhavesh.
--- ---------------------------------------------------
-
Bhavesh
Globsyn Finishing School
(a division of Globsyn Skills)
Document sign date :11 Jul, 2015

More Related Content

Similar to SVIMCS(Sonarpur)-JEE-Gr21

Similar to SVIMCS(Sonarpur)-JEE-Gr21 (20)

Knots - the Lazy Data Transfer Objects for Dealing with the Microservices Craze
Knots - the Lazy Data Transfer Objects for Dealing with the Microservices CrazeKnots - the Lazy Data Transfer Objects for Dealing with the Microservices Craze
Knots - the Lazy Data Transfer Objects for Dealing with the Microservices Craze
 
Introduction to OData
Introduction to ODataIntroduction to OData
Introduction to OData
 
Da água pro vinho, o caminho do desenvolvimento web Java
Da água pro vinho, o caminho do desenvolvimento web JavaDa água pro vinho, o caminho do desenvolvimento web Java
Da água pro vinho, o caminho do desenvolvimento web Java
 
Learned lessons in a real world project by Luis Rovirosa at PHPMad
Learned lessons in a real world project by Luis Rovirosa at PHPMadLearned lessons in a real world project by Luis Rovirosa at PHPMad
Learned lessons in a real world project by Luis Rovirosa at PHPMad
 
Boost Your Development With Proper API Design
Boost Your Development With Proper API DesignBoost Your Development With Proper API Design
Boost Your Development With Proper API Design
 
Open social
Open socialOpen social
Open social
 
Seko institutional furniture -final-z new-3-n
Seko institutional furniture -final-z new-3-nSeko institutional furniture -final-z new-3-n
Seko institutional furniture -final-z new-3-n
 
Open Social Introduction - JUG SummerCamp 2010
Open Social Introduction - JUG SummerCamp 2010Open Social Introduction - JUG SummerCamp 2010
Open Social Introduction - JUG SummerCamp 2010
 
Drupal 8 configuration system for coders and site builders - Drupalaton 2013
Drupal 8 configuration system for coders and site builders - Drupalaton 2013Drupal 8 configuration system for coders and site builders - Drupalaton 2013
Drupal 8 configuration system for coders and site builders - Drupalaton 2013
 
Consume Spring Data Rest with Angularjs
Consume Spring Data Rest with AngularjsConsume Spring Data Rest with Angularjs
Consume Spring Data Rest with Angularjs
 
Make it SOLID!
Make it SOLID!Make it SOLID!
Make it SOLID!
 
Data Science Amsterdam - Massively Parallel Processing with Procedural Languages
Data Science Amsterdam - Massively Parallel Processing with Procedural LanguagesData Science Amsterdam - Massively Parallel Processing with Procedural Languages
Data Science Amsterdam - Massively Parallel Processing with Procedural Languages
 
Встреча Google Post IO ( Владимир Иванов, Катерина Заворотченко и Сергей Комлач)
Встреча Google Post IO ( Владимир Иванов, Катерина Заворотченко и Сергей Комлач)Встреча Google Post IO ( Владимир Иванов, Катерина Заворотченко и Сергей Комлач)
Встреча Google Post IO ( Владимир Иванов, Катерина Заворотченко и Сергей Комлач)
 
A evolução da persistência de dados (com sqlite) no android
A evolução da persistência de dados (com sqlite) no androidA evolução da persistência de dados (com sqlite) no android
A evolução da persistência de dados (com sqlite) no android
 
Power your apps with Gmail, Google Drive, Calendar, Sheets, Slides & more
Power your apps with Gmail, Google Drive, Calendar, Sheets, Slides & morePower your apps with Gmail, Google Drive, Calendar, Sheets, Slides & more
Power your apps with Gmail, Google Drive, Calendar, Sheets, Slides & more
 
Creating a Facebook Clone - Part XX - Transcript.pdf
Creating a Facebook Clone - Part XX - Transcript.pdfCreating a Facebook Clone - Part XX - Transcript.pdf
Creating a Facebook Clone - Part XX - Transcript.pdf
 
JDD 2016 - Jakub Kubrynski - Jpa - beyond copy-paste
JDD 2016 - Jakub Kubrynski - Jpa - beyond copy-pasteJDD 2016 - Jakub Kubrynski - Jpa - beyond copy-paste
JDD 2016 - Jakub Kubrynski - Jpa - beyond copy-paste
 
inventory mangement project.pdf
inventory mangement project.pdfinventory mangement project.pdf
inventory mangement project.pdf
 
Easy path to machine learning (2022)
Easy path to machine learning (2022)Easy path to machine learning (2022)
Easy path to machine learning (2022)
 
Having Fun with Kotlin Android - DILo Surabaya
Having Fun with Kotlin Android - DILo SurabayaHaving Fun with Kotlin Android - DILo Surabaya
Having Fun with Kotlin Android - DILo Surabaya
 

SVIMCS(Sonarpur)-JEE-Gr21

  • 2. www.globsynskills.com 2 Globsyn Skills, Globsyn Crystals, 1 st Floor, XI – 11 and 12, Block EP, Sector V, Salt Lake, Kolkata – 700091 MNREGA PORTAL USING JEE Document sign date :11 Jul, 2015
  • 3. www.globsynskills.com 3 Group Members: MANISHA AGARWAL,JALPAIGURI GOVT. ENGG. COLLEGE,REG NO.131010110092 ANWESHA BHOWMIK,JALPAIGURI GOVT. ENGG. COLLEGE,REG NO.131010110068 ATANU DEB,JALPAIGURI GOVT. ENGG. COLLEGE,REG NO.131010110073 KRITI PAL,JALPAIGURI GOVT. ENGG. COLLEGE,REG NO.131010110016 MADHUMITA DAS,JALPAIGURI GOVT. ENGG. COLLEGE,REG NO.131010110018 Table of Contents Acknowledgement .................................................................................................................................. 5 Project objective…..……………………………………………………………………………………………………………………………5 Project Scope .......................................................................................................................................... 5 Requirement Specification...................................................................................................................... 6 Database Design...................................................................................................................................... 7 Application Work Flow............................................................................................................................ 8 E-R Diagram……………………………………………………………………………………………………………………………………….9 Screenshots...................................................................................................................................... 10-14 Document sign date :11 Jul, 2015
  • 4. www.globsynskills.com 4 Future Scope of Improvements ............................................................................................................ 15 Code ................................................................................................................................................. 17-66 Certificate…………………………………………………………………………………………………………………………………..67-71 Document sign date :11 Jul, 2015
  • 5. www.globsynskills.com 5 Acknowledgement I take this opportunity to express my profound gratitude and deep regards to my faculty Mr. Bhavesh for his exemplary guidance, monitoring and constant encouragement throughout the course of this project. The blessing, help and guidance given by him time to time shall carry me a long way in the journey of life on which I am about to embark. I am obliged to my project team members for the valuable information provided by them in their respective fields. I am grateful for their cooperation during the period of my assignment. MANISHA AGARWAL ANWESHA BHOWMIK ATANU DEB Document sign date :11 Jul, 2015
  • 6. www.globsynskills.com 6 KRITI PAL MADHUMITA DAS Project Objective Development and implementation of an online management system for the MAHATMA GANDHI NATIONAL RURAL EMPLOYMENT GUARANTEE ACT (MNREGA). This system will provide the organization a systematic way of allowing users to • Add projects • Add employees • Keep track of count of employees • Keep track of count of projects Document sign date :11 Jul, 2015 Edited with the trial version of Foxit Advanced PDF Editor To remove this notice, visit: www.foxitsoftware.com/shopping
  • 7. www.globsynskills.com 7 Project Scope  BDO and GPM can login their respective account with their User name and password.  BDO can create projects and GPMS can allocate projects and also can see the details of the employees.  GPM can create employees and enlist their details in the system and allocate project to them for work. Requirement Specification Document sign date :11 Jul, 2015
  • 8. www.globsynskills.com 8 HARDWARE: 1. Windows 7 (OS) 2. 4GB RAM SOFTWARE: 1. Eclipse Luna 2. Wildfly 8.1.0.Final 3. jdk-8u25-windows-x64 Document sign date :11 Jul, 2015
  • 10. www.globsynskills.com 10 Application Work Flow Document sign date :11 Jul, 2015
  • 12. www.globsynskills.com 12 Screenshots Homepage, BDO Homepage,Form of project details Document sign date :11 Jul, 2015
  • 13. www.globsynskills.com 13 Form of project details, List of Projects,Form of Project Details Document sign date :11 Jul, 2015
  • 14. www.globsynskills.com 14 Project Details, Form of Remove Project, Homepage Document sign date :11 Jul, 2015
  • 15. www.globsynskills.com 15 Gram Panchayet Homepage, Form for Register employee, List of Employee Document sign date :11 Jul, 2015
  • 17. www.globsynskills.com 17 Future Scope of Improvements • Registration of multiple B.D.O. • Auto-calculation of wages for employees. • Auto-calculation of number of days for a project. • Auto-calculation of number of days worked by an employee Document sign date :11 Jul, 2015
  • 18. www.globsynskills.com 18 Code Core Model:- Bean Classes:- Employee class- package com.vt.project.beans; import java.util.Date; public class Employee { private int e_id; private String e_name; private long e_contact; private int e_age; private String e_address; Project project; public Employee(){} public Employee(int e_id, String e_name, long e_contact, int e_age, String e_address, Project project) { super(); this.e_id = e_id; this.e_name = e_name; this.e_contact = e_contact; this.e_age = e_age; this.e_address = e_address; this.project = project; } public int getE_id() { return e_id; } public void setE_id(int e_id) { this.e_id = e_id; } public String getE_name() { return e_name; } public void setE_name(String e_name) { Document sign date :11 Jul, 2015
  • 19. www.globsynskills.com 19 this.e_name = e_name; } public long getE_contact() { return e_contact; } public void setE_contact(long e_contact) { this.e_contact = e_contact; } public int getE_age() { return e_age; } public void setE_age(int e_age) { this.e_age = e_age; } public String getE_address() { return e_address; } public void setE_address(String e_address) { this.e_address = e_address; } public Project getProject() { return project; } public void setProject(Project project) { this.project = project; } @Override public String toString() { return "Employee_table [e_name=" + e_name + "]"; } } Project class- package com.vt.project.beans; import java.util.*; Document sign date :11 Jul, 2015
  • 20. www.globsynskills.com 20 public class Project { private int p_id; private String p_name; private String p_desc; private int p_duration; private String p_location; public Project(){} public Project(int p_id, String p_name, String p_desc, int p_duration, String p_location) { super(); this.p_id = p_id; this.p_name = p_name; this.p_desc = p_desc; this.p_duration = p_duration; this.p_location = p_location; } @Override public String toString() { return "Project_table [p_name=" + p_name + "]"; } public int getP_id() { return p_id; } public void setP_id(int p_id) { this.p_id = p_id; } public String getP_name() { return p_name; } public void setP_name(String p_name) { this.p_name = p_name; } public String getP_desc() { return p_desc; } public void setP_desc(String p_desc) { this.p_desc = p_desc; Document sign date :11 Jul, 2015
  • 21. www.globsynskills.com 21 } public int getP_duration() { return p_duration; } public void setP_duration(int p_duration) { this.p_duration = p_duration; } public String getP_location() { return p_location; } public void setP_location(String p_location) { this.p_location = p_location; } } User Class- package com.vt.project.beans; public class User { private int u_id; private String u_name; private String u_email; private String u_password; private String u_role; public User(){} public User(int u_id, String u_name, String u_email, String u_password, String u_role) { super(); this.u_id = u_id; this.u_name = u_name; this.u_email = u_email; this.u_password = u_password; this.u_role = u_role; } public int getU_id() { return u_id; } Document sign date :11 Jul, 2015
  • 22. www.globsynskills.com 22 public void setU_id(int u_id) { this.u_id = u_id; } public String getU_name() { return u_name; } public void setU_name(String u_name) { this.u_name = u_name; } public String getU_email() { return u_email; } public void setU_email(String u_email) { this.u_email = u_email; } public String getU_password() { return u_password; } public void setU_password(String u_password) { this.u_password = u_password; } public String getU_role() { return u_role; } public void setU_role(String u_role) { this.u_role = u_role; } @Override public String toString() { return "user_table [u_name=" + u_name + "]"; } } Util classes:- DBUtils class- package com.vt.project.utils; Document sign date :11 Jul, 2015
  • 23. www.globsynskills.com 23 import java.sql.*; public class DBUtils { static Connection con = null; static Statement st = null; static PreparedStatement pst = null; static ResultSet rs = null; public static Connection getConnected(){ String user = "root"; String pass = ""; String url = "jdbc:mysql://localhost:3306/project_db"; try { Class.forName("com.mysql.jdbc.Driver"); con = DriverManager.getConnection(url, user, pass); } catch (ClassNotFoundException e) { e.printStackTrace(); } catch(SQLException e){ e.printStackTrace(); } return con; } public static Statement getStatement(){ try { st=con.createStatement(); } catch (SQLException e) { e.printStackTrace(); } return st; } public static PreparedStatement getPreparedStatement(String sql){ try { pst = con.prepareStatement(sql); Document sign date :11 Jul, 2015
  • 24. www.globsynskills.com 24 } catch (SQLException e) { e.printStackTrace(); } return pst; } public static void releaseResources(){ try{ if(rs != null) rs.close(); if(pst != null) pst.close(); if(st != null) st.close(); if(con != null) con.close(); }catch(SQLException e){ e.printStackTrace(); } } } BDOUseutils interface- package com.vt.project.utils; import com.vt.project.beans.*; import java.util.*; public interface BDOUserutils { public User login(String email,String password,String role); public boolean registerProject(Project project); public boolean removeproject(int p_id,String p_name); Document sign date :11 Jul, 2015
  • 25. www.globsynskills.com 25 public List<Project> viewAllProjects(); public Project detailOfProject(int p_id,String p_name); public List<Employee> viewProjectEmployee(int p_id); } BDOUserutilsimpl class- package com.vt.project.utils; import java.sql.*; import java.util.ArrayList; import java.util.List; import com.vt.project.utils.*; import com.vt.project.beans.Employee; import com.vt.project.beans.Project; import com.vt.project.beans.User; public class BDOUserutilsimpl implements BDOUserutils{ Connection con=null; PreparedStatement pst=null; ResultSet rs=null; int result=0; public User login(String email,String password,String role) { User user=null; con=DBUtils.getConnected(); String sql="select * from user_table where u_email=? AND u_password=? AND u_role=?"; pst=DBUtils.getPreparedStatement(sql); try { pst.setString(1,email); pst.setString(2, password); pst.setString(3, role); rs=pst.executeQuery(); if(rs!=null) { if(rs.next()){ Document sign date :11 Jul, 2015
  • 26. www.globsynskills.com 26 user=new User(); user.setU_id(rs.getInt(1)); user.setU_name(rs.getString(2)); user.setU_email(rs.getString(3)); user.setU_password(rs.getString(4)); user.setU_role(rs.getString(5)); } } } catch(SQLException e){ e.printStackTrace(); } finally { DBUtils.releaseResources(); } return user; } public boolean registerProject(Project project) { boolean isRegistered = false; con = DBUtils.getConnected(); String sql = "insert into project_table (p_id,p_name,p_desc,p_location,p_duration) values (?,?,?,?,?)"; pst = DBUtils.getPreparedStatement(sql); try{ pst.setInt(1, project.getP_id()); pst.setString(2, project.getP_name()); pst.setString(3, project.getP_desc()); pst.setString(4, project.getP_location()); pst.setInt(5, project.getP_duration()); result = pst.executeUpdate(); }catch(SQLException e){ e.printStackTrace(); }finally{ DBUtils.releaseResources(); } if(result >0) Document sign date :11 Jul, 2015
  • 27. www.globsynskills.com 27 isRegistered = true; return isRegistered; } public List<Project> viewAllProjects() { List<Project> plist= new ArrayList<Project>(); con = DBUtils.getConnected(); String sql = "select * from project_table"; pst = DBUtils.getPreparedStatement(sql); try{ rs = pst.executeQuery(); if(rs!=null){ while(rs.next()){ Project project = new Project(); project.setP_id(rs.getInt(1)); project.setP_name(rs.getString(2)); project.setP_desc(rs.getString(3)); project.setP_duration(rs.getInt(5)); project.setP_location(rs.getString(4)); plist.add(project); } } }catch(SQLException e){ e.printStackTrace(); } return plist; } public Project detailOfProject(int p_id,String p_name){ Project project = null; con = DBUtils.getConnected(); String sql = "select * from project_table where p_id=? AND p_name=?"; pst = DBUtils.getPreparedStatement(sql); try{ pst.setInt(1, p_id); pst.setString(2, p_name); Document sign date :11 Jul, 2015
  • 28. www.globsynskills.com 28 rs = pst.executeQuery(); if(rs != null){ while(rs.next()){ project = new Project(); project.setP_id(rs.getInt(1)); project.setP_name(rs.getString(2)); project.setP_desc(rs.getString(3)); project.setP_duration(rs.getInt(5)); project.setP_location(rs.getString(4)); } } } catch (SQLException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } DBUtils.releaseResources(); return project; } public List<Employee> viewProjectEmployee(int p_id){ List<Employee> empList = new ArrayList<Employee>(); Employee emp = null; con = DBUtils.getConnected(); String sql = "select * from Employee_table where p_id=?"; pst = DBUtils.getPreparedStatement(sql); try { pst.setInt(1,p_id ); rs = pst.executeQuery(); if(rs != null){ while(rs.next()){ emp = new Employee(); emp.setE_id(rs.getInt(1)); emp.setE_name(rs.getString(2)); emp.setE_age(rs.getInt(3)); emp.setE_address(rs.getString(4)); emp.setE_contact(rs.getLong(6)); empList.add(emp); } } Document sign date :11 Jul, 2015
  • 29. www.globsynskills.com 29 } catch (SQLException e) { e.printStackTrace(); } DBUtils.releaseResources(); return empList; } public boolean removeproject(int p_id,String p_name) { con = DBUtils.getConnected(); int res=0; boolean isremoved=false; String sql = "delete from project_table where p_id=? AND p_name=?"; pst = DBUtils.getPreparedStatement(sql); try { pst.setInt(1,p_id ); pst.setString(2,p_name); res = pst.executeUpdate(); } catch(SQLException e){ e.printStackTrace(); }finally{ DBUtils.releaseResources(); } if(res >0) isremoved= true; else System.out.println("Deletion not possible"); return isremoved; } } GPUserutils interface- package com.vt.project.utils; import java.util.*; import com.vt.project.beans.*; Document sign date :11 Jul, 2015
  • 30. www.globsynskills.com 30 public interface GPUserutils { public User login(String email,String password,String role); public boolean logout(User user); public boolean registerEmployee(Employee emp); public List<Employee> viewAllEmployee(); public Employee detailOfEmployee(int e_id,String e_name); } GPUserutilsimpl class- package com.vt.project.utils; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.util.*; import com.vt.project.utils.*; import com.vt.project.beans.*; public class GPUserutilsimpl implements GPUserutils { Connection con = null; PreparedStatement pst = null; ResultSet rs = null; int result = 0; public User login(String email, String password, String role) { User user = null; con = DBUtils.getConnected(); String sql = "select * from user_table where u_email=? AND u_password=? AND u_role=?"; pst = DBUtils.getPreparedStatement(sql); try { pst.setString(1, email); pst.setString(2, password); pst.setString(3, role); rs = pst.executeQuery(); if (rs != null) { if (rs.next()) { user = new User(); user.setU_id(rs.getInt(1)); user.setU_name(rs.getString(2)); user.setU_email(rs.getString(3)); Document sign date :11 Jul, 2015
  • 31. www.globsynskills.com 31 user.setU_password(rs.getString(4)); user.setU_role(rs.getString(5)); } } } catch (SQLException e) { e.printStackTrace(); } finally { DBUtils.releaseResources(); } return user; } public boolean logout(User user) { return false; } public boolean registerEmployee(Employee emp) { boolean isRegistered = false; con = DBUtils.getConnected(); String sql = "insert into Employee_table (e_name,e_age,e_address,p_id,e_contact) values (?,?,?,?,?)"; pst = DBUtils.getPreparedStatement(sql); int result = 0; try { // pst.setInt(1, e.getE_id()); pst.setString(1, emp.getE_name()); pst.setInt(2, emp.getE_age()); pst.setString(3, emp.getE_address()); pst.setInt(4, emp.getProject().getP_id()); pst.setLong(5, emp.getE_contact()); result = pst.executeUpdate(); } catch (SQLException e) { e.printStackTrace(); } finally { DBUtils.releaseResources(); } if (result > 0) { isRegistered = true; Document sign date :11 Jul, 2015
  • 32. www.globsynskills.com 32 } return isRegistered; } public List<Employee> viewAllEmployee() { List<Employee> empList = new ArrayList<Employee>(); con = DBUtils.getConnected(); String sql = "select * from Employee_table"; pst = DBUtils.getPreparedStatement(sql); try { rs = pst.executeQuery(); if (rs != null) { while (rs.next()) { Employee emp = new Employee(); emp.setE_id(rs.getInt(1)); emp.setE_name(rs.getString(2)); emp.setE_age(rs.getInt(3)); emp.setE_address(rs.getString(4)); Project p = new Project(); p.setP_id(rs.getInt(5)); emp.setProject(p); emp.setE_contact(rs.getLong(6)); empList.add(emp); } } } catch (SQLException e) { e.printStackTrace(); } DBUtils.releaseResources(); return empList; } public Employee detailOfEmployee(int e_id, String e_name) { Employee emp = null; con = DBUtils.getConnected(); String sql = "select * from employee_table where e_id=? AND e_name=?"; pst = DBUtils.getPreparedStatement(sql); try { Document sign date :11 Jul, 2015
  • 33. www.globsynskills.com 33 pst.setInt(1, e_id); pst.setString(2, e_name); rs = pst.executeQuery(); if (rs != null) { while (rs.next()) { emp = new Employee(); emp.setE_id(rs.getInt(1)); emp.setE_name(rs.getString(2)); emp.setE_age(rs.getInt(3)); emp.setE_address(rs.getString(4)); emp.setE_contact(rs.getLong(6)); } } } catch (SQLException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } DBUtils.releaseResources(); return emp; } } Code for Login:- package com.vt.project.servlet; import java.io.IOException; import com.vt.project.*; import com.vt.project.utils.*; import com.vt.project.beans.*; import javax.servlet.*; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; /** * Servlet implementation class Loginservlet */ Document sign date :11 Jul, 2015
  • 34. www.globsynskills.com 34 @WebServlet("/Loginservlet") public class Loginservlet extends HttpServlet { public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String email = request.getParameter("mail"); String password = request.getParameter("upass"); String role = request.getParameter("loginAs"); if(role.equals("BDO")) { BDOUserutilsimpl u = new BDOUserutilsimpl(); User user = u.login(email, password, role); if(user != null){ HttpSession session = request.getSession(true); session.setAttribute("user", user); RequestDispatcher rd = request.getRequestDispatcher("BDOHome.jsp"); rd.forward(request, response); }else{ request.setAttribute("valid", "false"); RequestDispatcher rd = request.getRequestDispatcher("Home.jsp"); rd.forward(request, response); } }else if(role.equals("GP")){ GPUserutilsimpl gp=new GPUserutilsimpl(); User user=gp.login(email, password, role); if(user != null){ HttpSession session = request.getSession(true); session.setAttribute("user", user); RequestDispatcher rd = request.getRequestDispatcher("GPHome.jsp"); rd.forward(request, response); }else{ request.setAttribute("valid", "false"); Document sign date :11 Jul, 2015
  • 35. www.globsynskills.com 35 RequestDispatcher rd = request.getRequestDispatcher("Home.jsp"); rd.forward(request, response); } } } public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { doGet(request,response); } } Login JSP :- <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Insert title here</title> </head> <body bgcolor='khaki'> <img src="HomeHeaderImage.jpg.gif" align="top" width="100%"> <center> <h2 style="font-family:Bradley Hand ITC;color:blue;"><u>The Mahatma Gandhi Rural Employement Gurantee Act</u></h2> </center> <hr width="100%" color="red"> <center><p style="font-family:Viner Hand ITC;color:brown;">Please login to continue...</p></center> <form method="POST" action="Loginservlet"> <table border="1" align="center"> <tr> <td>Email ID :</td> Document sign date :11 Jul, 2015
  • 36. www.globsynskills.com 36 <td><input type="text" name="mail"></td> </tr> <tr> <td>Password :</td> <td><input type="password" name="upass"></td> </tr> <tr> <td>Login As :</td> <td><select name="loginAs"> <option value="">Select</option> <option value="BDO">BDO</option> <option value="GP">GRAMPANCHAYET</option> </select></td> </tr> <tr> <td colspan="2" align="right"><input type="submit" value="Login" name="sub"></td> </tr> <% String valid = (String) request.getAttribute("valid"); if (valid != null) { if (valid.equals("false")) { %> <tr> <td colspan="2">Please check email, password OR role...!</td> </tr> <% } } %> </table> </form> </body> </html> Document sign date :11 Jul, 2015
  • 37. www.globsynskills.com 37 BDOHome.jsp- <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO- 8859-1"> <title><b>Welcome</b></title> </head> <body bgcolor="NavajoWhite" > <img src="NREGA.jpg" align="top" width=100%> <h2 style="font-family:Cooper Black;color:chocolate;"><u> WELCOME </u></h2> <ul type="square"> <li><a href="AddProject.jsp"> Add a new project</br></a></li> <li><a href="ListofProject">View all registered projects</br></a></li> <li><a href="projectform.jsp">View details of a project</br></a></li> <li><a href="ProjectEmployees.jsp">View list of employees in a project</br></a></li> <li><a href="RemoveProject.jsp">Delete a project</br></a></li> <li><a href="Tologout.jsp">LOGOUT</a></li> </ul> </body> </html> GPHome.jsp- <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO- 8859-1"> Document sign date :11 Jul, 2015
  • 38. www.globsynskills.com 38 <title>Welcome</title> </head> <body bgcolor="NavajoWhite" > <img src="NREGA.jpg" align="top" width="100%"> < <h2 style="font-family:Cooper Black;color:chocolate;"><u> WELCOME </u></h2> <ul type="square"> <body bgcolor="aquamarine"> <li><a href="Addemployee"> Add a new employee and assign a project</br></a></li> <li><a href="ListofEmployee">View all registered employees</br></a></li> <li><a href="empdetailform.jsp">View employee details</br></a></li> <li><a href="Tologout.jsp">BACK</a></li> </body> </html> Code for Project Registration:- <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <%@ page import="com.vt.project.beans.*"%> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>AddProject</title> </head> <body background="big1.jpg" > <img src="MGNREGA_Logo.gif" align="left" height="550" width="50%"> <div style="text-align:right"> Document sign date :11 Jul, 2015
  • 39. www.globsynskills.com 39 <h2 style="font-family:Cooper Black;color:purple;"><u>FILL UP PROJECT DETAILS </u></h2> <ul type="square"> <form method="POST" action="Addproject1"> <table border="0" align="center"> <% String status = (String) request.getAttribute("added"); %> <% if (status != null && status.equals("yes")) { %> <tr> <td colspan="2">Project Added Successfully..!</td> </tr> <% } else if (status != null && status.equals("no")) { %> <tr> <td colspan="2">Operation Failed..!</td> </tr> <% } %> <tr> <td>Project ID :</td> <td><input type="text" name="ID"></td> </tr> <tr> <td>Project name :</td> <td><input type="text" name="name"></td> </tr> <tr> <td>Descrption :</td> <td><input type="text" name="description"></td> Document sign date :11 Jul, 2015
  • 40. www.globsynskills.com 40 </tr> <tr> <td>Location :</td> <td><input type="text" name="location"></td> </tr> <tr> <td>Duration :</td> <td><input type="value" name="duration"></td> </tr> <tr> <td colspan="2" align="center"><input type="submit" value="Submit" name="sub"></td> </tr> </table> </form> <a href="BDOHome.jsp">Back to Home</a> </ul> </div> </body> </html> Servlet:- package com.vt.project.servlet; import com.vt.project.beans.*; import com.vt.project.utils.*; import java.io.IOException; import java.io.PrintWriter; import javax.servlet.RequestDispatcher; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; Document sign date :11 Jul, 2015
  • 41. www.globsynskills.com 41 import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; /** * Servlet implementation class addproject1 */ @WebServlet("/Addproject1") public class Addproject1 extends HttpServlet { protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { } protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { int id=Integer.parseInt(request.getParameter("ID")); String name=request.getParameter("name"); String descrip=request.getParameter("description"); String location=request.getParameter("location"); int duration=Integer.parseInt(request.getParameter("duration")); boolean a=false; Project pro=new Project(); pro.setP_id(id); pro.setP_name(name); pro.setP_desc(descrip); pro.setP_location(location); pro.setP_duration(duration); BDOUserutilsimpl u=new BDOUserutilsimpl(); a=u.registerProject(pro); if(a){ request.setAttribute("added", "yes"); RequestDispatcher rd = request.getRequestDispatcher("AddProject.jsp"); rd.forward(request, response); }else{ request.setAttribute("added", "no"); Document sign date :11 Jul, 2015
  • 42. www.globsynskills.com 42 RequestDispatcher rd = request.getRequestDispatcher("AddProject.jsp"); rd.forward(request, response); } } } Code for List of project:- package com.vt.project.servlet; import java.io.IOException; import java.util.List; import javax.servlet.RequestDispatcher; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import com.vt.project.beans.*; import com.vt.project.utils.*; @WebServlet("/ListofProject") public class ListofProject extends HttpServlet { protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { BDOUserutilsimpl u = new BDOUserutilsimpl(); List<Project> projects = u.viewAllProjects(); request.setAttribute("projectList", projects); RequestDispatcher rd = request.getRequestDispatcher("Projectlist.jsp"); rd.forward(request, response); } protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { doGet(request,response); } } Projectlist.jsp:- <%@ page language="java" contentType="text/html; charset=ISO-8859-1" Document sign date :11 Jul, 2015
  • 43. www.globsynskills.com 43 pageEncoding="ISO-8859-1"%> <%@page import="java.util.*,com.vt.project.beans.*" import ="com.vt.project.utils.*"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO- 8859-1"> <title>Insert title here</title> </head> <body background="big1.jpg" > <img src="MGNREGA_Logo.gif" align="left" height="550" width="50%"> <div style="text-align:right"> <h2 style="font-family:Cooper Black;color:purple;"><u>LIST OF PROJECTS </u></h2> <% List<Project> projects = (List<Project>)request.getAttribute("projectList"); %> <table align="center" border="1"> <tr> <th>Name</th> <th>Id</th> <th>Description</th> <th>Location</th> <th>Duration</th> <th></th> </tr> <% if (projects!= null) { for (Project pt:projects) { %> <tr> <td><%=pt.getP_name()%></td> <td><%=pt.getP_id()%></td> <td><%=pt.getP_desc()%></td> Document sign date :11 Jul, 2015
  • 44. www.globsynskills.com 44 <td><%=pt.getP_location()%></td> <td><%=pt.getP_duration()%></td> </tr> <% } projects = null; } else { %> <tr> <td colspan="5" align="center"> No projects Found..! </td> </tr> <% %> </table> <center><a href="BDOHome.jsp">GO TO HOME PAGE</a></center> </div> </body> </html> Code for detail of a particular project:- <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO- 8859-1"> <title>Insert title here</title> </head> <body background="big1.jpg" > <img src="MGNREGA_Logo.gif" align="left" height="550" width="50%"> <div style="text-align:right"> Document sign date :11 Jul, 2015
  • 45. www.globsynskills.com 45 <h2 style="font-family:Cooper Black;color:purple;"><u>PLEASE ENTER REQUIRED DATA </u></h2> <form method="POST" action="Prodetail"> <table border="0" align="center"> <tr> <td>Project ID :</td> <td><input type="value" name="ID"></td> </tr> <tr> <td>Project name :</td> <td><input type="text" name="name"></td> </tr> <tr> <td colspan="2" align="center"><input type="submit" value="Submit" name="sub"></td> </tr> </table> </form> </div> </body> </html> Servlet:- package com.vt.project.servlet; import java.io.IOException; import javax.servlet.RequestDispatcher; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import com.vt.project.*; import com.vt.project.beans.Project; import com.vt.project.servlet.*; import com.vt.project.utils.*; Document sign date :11 Jul, 2015
  • 46. www.globsynskills.com 46 @WebServlet("/Prodetail") public class Prodetail extends HttpServlet { protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { int p_id = Integer.parseInt(request.getParameter("ID")); String p_name=request.getParameter("name"); BDOUserutilsimpl u = new BDOUserutilsimpl(); Project projects = u.detailOfProject(p_id,p_name); request.setAttribute("projectDetails", projects); RequestDispatcher rd = request.getRequestDispatcher("ProjectinDetail.jsp"); rd.forward(request, response); } protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { doGet(request, response); } } Projectindetail.jsp:- <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <%@page import="com.vt.project.beans.*"%> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Insert title here</title> </head> <body background="big1.jpg" > <img src="MGNREGA_Logo.gif" align="left" height="550" width="50%"> <div style="text-align:right"> <h2 style="font-family:Cooper Black;color:purple;"><u>PROJECT DETAIL </u></h2> <% Document sign date :11 Jul, 2015
  • 47. www.globsynskills.com 47 Project pro = (Project)request.getAttribute("projectDetails"); %> <table border="1" align="center"> <tr> <td colspan="2"><b>Project Details</b></td> </tr> <tr> <td>Id :</td><td><%=pro.getP_id() %></td> </tr> <tr> <td>Name :</td><td><%=pro.getP_name() %></td> </tr> <tr> <td>Description :</td><td><%=pro.getP_desc() %></td> </tr> <tr> <td>Location :</td><td><%=pro.getP_location() %></td> </tr> <tr> <td>Duration :</td><td><%=pro.getP_duration() %></td> </tr> </table> <a href="BDOHome.jsp">Home Page</a>||<a href="projectform.jsp">Back Page</a> </div> </body> </html> Code for list of employee in a particular project:- <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO- 8859-1"> Document sign date :11 Jul, 2015
  • 48. www.globsynskills.com 48 <title>Insert title here</title> </head> <body background="big1.jpg" > <img src="MGNREGA_Logo.gif" align="left" height="550" width="50%"> <div style="text-align:right"> <h2 style="font-family:Cooper Black;color:purple;"><u>PLEASE ENTER REQUIRED DATA </u></h2> <form method="POST" action="Projectemp"> <table border="0" align="center"> <tr> <td>Project ID :</td> <td><input type="value" name="p_id"></td> </tr> <tr> <td colspan="2" align="center"><input type="submit" value="Submit" name="sub"></td> </tr> </table></form> </div> </body> </html> Servlet:- package com.vt.project.servlet; import com.vt.project.beans.*; import com.vt.project.utils.*; import java.io.IOException; import java.util.List; import javax.servlet.RequestDispatcher; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; /** Document sign date :11 Jul, 2015
  • 49. www.globsynskills.com 49 * Servlet implementation class projectemp */ @WebServlet("/Projectemp") public class Projectemp extends HttpServlet { protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { int p_id = Integer.parseInt(request.getParameter("id")); BDOUserutils u = new BDOUserutilsimpl(); List<Employee> emp= u.viewProjectEmployee(p_id); request.setAttribute("emp", emp); RequestDispatcher rd = request.getRequestDispatcher("projectemp1.jsp"); rd.forward(request, response); } protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { doGet(request, response); } } Projectemp1.jsp:- <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <%@page import="com.vt.project.beans.*" import="java.util.*"%> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Insert title here</title> </head> Document sign date :11 Jul, 2015
  • 50. www.globsynskills.com 50 <body background="big1.jpg" > <img src="MGNREGA_Logo.gif" align="left" height="550" width="50%"> <div style="text-align:right"> <h2 style="font-family:Cooper Black;color:purple;"><u>EMPLOYEE DETAIL</u></h2> <% List<Employee> emp = (List<Employee>)request.getAttribute("emp"); %> <table align="center" border="1"> <tr> <th>ID</th> <th>NAME</th> <th>AGE</th> <th>ADDRESS</th> <th>CONTACT NO</th> </tr> <% if (emp!= null) { for (Employee e:emp) { %> <tr> <td><%=e.getE_id()%></td> <td><%=e.getE_name()%></td> <td><%=e.getE_age()%></td> <td><%=e.getE_address()%></td> <td><%=e.getE_contact()%></td> </tr> <% } emp = null; } else { %> <tr> <td colspan="5" align="center"> opertion failed! </td> </tr> <% } Document sign date :11 Jul, 2015
  • 51. www.globsynskills.com 51 %> </table> <a href="BDOHome.jsp">Home Page</a> </div> </body> </html> Code for removing a project:- <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO- 8859-1"> <title>Insert title here</title> </head> <body background="big1.jpg" > <img src="MGNREGA_Logo.gif" align="left" height="550" width="50%"> <div style="text-align:right"> <form method="POST" action="Remove"> <table border="0" align="center"> <tr> <td>Project ID :</td> <td><input type="text" name="ID"></td> </tr> <tr> <td>Project name :</td> <td><input type="text" name="name"></td> </tr> <tr><td><input type="submit" name="remove"></td></tr> </table> </form> </div> Document sign date :11 Jul, 2015
  • 52. www.globsynskills.com 52 </body> </html> Servlet:- package com.vt.project.servlet; import java.io.IOException; import javax.servlet.RequestDispatcher; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import com.vt.project.utils.BDOUserutilsimpl; /** * Servlet implementation class remove */ @WebServlet("/Remove") public class Remove extends HttpServlet { protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { boolean a=false; int id=Integer.parseInt(request.getParameter("ID")); String name=request.getParameter("name"); BDOUserutilsimpl u=new BDOUserutilsimpl(); a=u.removeproject(id,name); if(a){ request.setAttribute("removed", "yes"); RequestDispatcher rd = request.getRequestDispatcher("remove1.jsp"); rd.forward(request, response); }else{ request.setAttribute("removed", "no"); RequestDispatcher rd = request.getRequestDispatcher("remove1.jsp"); rd.forward(request, response); } } /** Document sign date :11 Jul, 2015
  • 53. www.globsynskills.com 53 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) */ protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // TODO Auto-generated method stub doGet(request,response); } } remove1.jsp:- <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <%@page import="com.vt.project.utils.*" import="com.vt.project.beans.*" import="java.sql.*"%> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO- 8859-1"> <title>Insert title here</title> </head> <body background="big1.jpg" > <img src="MGNREGA_Logo.gif" align="left" height="550" width="50%"> <div style="text-align:right"> <h2 style="font-family:Cooper Black;color:purple;"><u> </u></h2> <% String a = (String) request.getAttribute("removed"); %> <% if (a != null && a.equals("yes")) { %> <tr> Document sign date :11 Jul, 2015
  • 54. www.globsynskills.com 54 <td colspan="2">Project removed Successfully..!</td> </tr> <% } else if (a != null && a.equals("no")) { %> <tr> <td colspan="2">EMPLOYEES ARE ENGAGED IN THIS PROCESS</BR>SORRY!!CANNOT BE DELETED</td> </tr> <% } %> <a href="ListofProject">List of updated projects></a> </div> </body> </html> Code for registering employee by GP:- Servlet: package com.vt.project.servlet; import java.io.IOException; import javax.servlet.RequestDispatcher; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import java.util.List; import com.vt.project.beans.Project; import com.vt.project.utils.BDOUserutils; import com.vt.project.utils.BDOUserutilsimpl; /** * Servlet implementation class AddEmployeePreparerServlet */ @WebServlet("/Addemployee") Document sign date :11 Jul, 2015
  • 55. www.globsynskills.com 55 public class AddEmployeePreparerServlet extends HttpServlet { protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { BDOUserutils u = new BDOUserutilsimpl(); List<Project> pList = u.viewAllProjects(); HttpSession session = request.getSession(false); session.setAttribute("projects", pList); RequestDispatcher rd = request.getRequestDispatcher("Addemployee.jsp"); rd.forward(request, response); } } Servlet:- package com.vt.project.servlet; import java.io.IOException; import javax.servlet.RequestDispatcher; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import com.vt.project.beans.Employee; import com.vt.project.beans.Project; import com.vt.project.utils.BDOUserutilsimpl; import com.vt.project.utils.GPUserutilsimpl; /** * Servlet implementation class AddEmployee */ @WebServlet("/AddEmployee") public class AddEmployee extends HttpServlet { protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { } Document sign date :11 Jul, 2015
  • 56. www.globsynskills.com 56 /** * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) */ protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String name=request.getParameter("name"); int age=Integer.parseInt(request.getParameter("age")); String address=request.getParameter("address"); int pid=Integer.parseInt(request.getParameter("PID")); long contact=Long.parseLong(request.getParameter("contact")); boolean a=false; Employee e=new Employee(); e.setE_name(name); e.setE_age(age); e.setE_address(address); Project p=new Project(); p.setP_id(pid); e.setProject(p); e.setE_contact(contact); GPUserutilsimpl u=new GPUserutilsimpl(); a=u.registerEmployee(e); if(a){ request.setAttribute("added", "yes"); RequestDispatcher rd = request.getRequestDispatcher("Addemployee.jsp"); rd.forward(request, response); }else{ request.setAttribute("added", "no"); RequestDispatcher rd = request.getRequestDispatcher("Addemployee.jsp"); rd.forward(request, response); } } } Document sign date :11 Jul, 2015
  • 57. www.globsynskills.com 57 Addemployee.jsp:- <%@page import="com.vt.project.beans.Project"%> <%@page import="java.util.*"%> <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO- 8859-1"> <title><b>EMPLOYEE REGISTRATION</b></title> </head> <body background="big1.jpg" > <img src="MGNREGA_Logo.gif" align="left" height="550" width="50%"> <div style="text-align:right"> <h2 style="font-family:Cooper Black;color:purple;"><u>Enter Employee Details</u></h2> <% List<Project> plist = (List<Project>)session.getAttribute("projects"); %> <center> <h2></h2> </center> <form method="POST" action="AddEmployee"> <table border="0" align="right" WIDTH="50%" HEIGHT="250" > <% String status = (String) request.getAttribute("added"); %> <% if (status != null && status.equals("yes")) { %> Document sign date :11 Jul, 2015
  • 58. www.globsynskills.com 58 <tr> <td colspan="5">Employee Added Successfully..!</td> </tr> <% } else if (status != null && status.equals("no")) { %> <tr> <td colspan="5">Operation Failed..!</td> </tr> <% } %> <tr> <td colspan="5"><font color=black face="geneva,arial"size=3>Employee name :</font></td> <td><input type="text" name="name"></td> </tr> <tr> <td colspan="5"><font color=black face="geneva,arial"size=3>Age :</font></td> <td><input type="value" name="age"></td> </tr> <tr> <td colspan="5"><font color=black face="geneva,arial"size=3>Address :</font></td> <td><input type="text" name="address"></td> </tr> <tr> <td colspan="5"><font color=black face="geneva,arial"size=3>Select Project :</font></td> <td><select name="PID"> <% Document sign date :11 Jul, 2015
  • 59. www.globsynskills.com 59 for(Project p : plist){ %> <option value="<%=p.getP_id()%>"><%=p.getP_name() %></option> <%} %> </select></td> </tr> <tr> <td colspan="5"><font color=black face="geneva,arial"size=3>Contact :</font></td> <td><input type="text" name="contact"></td> </tr> <tr> <td colspan="2" align="center"><input type="submit" value="Register Employee" name="sub"></td> </tr> </table> </form> <a href="GPHome.jsp">Back</a> </div> </body> </html> Code for list of employee:- package com.vt.project.servlet; import java.io.IOException; import java.util.List; import javax.servlet.RequestDispatcher; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; Document sign date :11 Jul, 2015
  • 60. www.globsynskills.com 60 import javax.servlet.http.HttpServletResponse; import com.vt.project.beans.Employee; import com.vt.project.beans.Project; import com.vt.project.utils.BDOUserutilsimpl; import com.vt.project.utils.GPUserutilsimpl; /** * Servlet implementation class ListofEmployee */ @WebServlet("/ListofEmployee") public class ListofEmployee extends HttpServlet { /** * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) */ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { GPUserutilsimpl u = new GPUserutilsimpl(); List<Employee> emps = u.viewAllEmployee(); request.setAttribute("EmployeeList", emps); RequestDispatcher rd = request.getRequestDispatcher("ListofEmployee.jsp"); rd.forward(request, response); } /** * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) */ protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { doGet(request,response); } } ListofEmployee.jsp:- <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> Document sign date :11 Jul, 2015
  • 61. www.globsynskills.com 61 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <%@ page import="com.vt.project.utils.*" import="java.util.*" import="com.vt.project.beans.*" import="java.sql.*" %> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO- 8859-1"> <title>List of all employees</title> </head> <body background="big1.jpg" > <img src="MGNREGA_Logo.gif" align="left" height="550" width="50%"> <div style="text-align:right"> <% List<Employee> e = (List<Employee>) request.getAttribute("EmployeeList"); %> <h2 style="font-family:Cooper Black;color:purple;"><u>LIST OF EMPLOYEE </u></h2> <table align="center" border="1"> <tr> <th>ID</th> <th>Name</th> <th>Age</th> <th>Address</th> <th>Project ID</th> <th>Contact</th> </tr> <% if (e!= null) { for (Employee emp:e) { %> <tr> <td><%=emp.getE_id()%></td> <td><%=emp.getE_name()%></td> Document sign date :11 Jul, 2015
  • 62. www.globsynskills.com 62 <td><%=emp.getE_age()%></td> <td><%=emp.getE_address()%></td> <td><%=emp.getProject().getP_id()%></td> <td><%=emp.getE_contact()%></td> </tr> <% } e = null; } else { %> <tr> <td colspan="5" align="center"> No employees Found..! </td> </tr> <% } %> </table> <a href="GPHome.jsp">BACK</a> </div> </body> </html> Code for detail of a particular employee:- <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO- 8859-1"> <title>Insert title here</title> </head> <body background="big1.jpg" > <img src="MGNREGA_Logo.gif" align="left" height="550" width="50%"> <div style="text-align:right"> <h2 style="font-family:Cooper Black;color:purple;"><u>PLEASE ENTER REQUIRED DATA </u></h2> Document sign date :11 Jul, 2015
  • 63. www.globsynskills.com 63 <form method="POST" action="Empdetail"> <table border="0" align="center"> <tr> <td>Employee ID :</td> <td><input type="value" name="ID"></td> </tr> <tr> <td>Employee name :</td> <td><input type="text" name="name"></td> </tr> <tr> <td colspan="2" align="center"><input type="submit" value="Submit" name="sub"></td> </tr> </table> </form> </div> </body> </html> Servlet:- package com.vt.project.servlet; import java.io.IOException; import javax.servlet.RequestDispatcher; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import com.vt.project.beans.Employee; import com.vt.project.beans.Project; import com.vt.project.utils.BDOUserutilsimpl; import com.vt.project.utils.GPUserutilsimpl; /** * Servlet implementation class Empdetail */ Document sign date :11 Jul, 2015
  • 64. www.globsynskills.com 64 @WebServlet("/Empdetail") public class Empdetail extends HttpServlet { protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { int e_id = Integer.parseInt(request.getParameter("ID")); String e_name=request.getParameter("name"); GPUserutilsimpl u = new GPUserutilsimpl(); Employee emp = u.detailOfEmployee(e_id,e_name); request.setAttribute("employeeDetails", emp); RequestDispatcher rd = request.getRequestDispatcher("empdetail.jsp"); rd.forward(request, response); } protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { doGet(request,response); } } empdetail.jsp:- <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> <%@ page import="com.vt.project.beans.*" %> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO- 8859-1"> <title>Insert title here</title> </head> <body background="big1.jpg" > <img src="MGNREGA_Logo.gif" align="left" height="550" width="50%"> <div style="text-align:right"> Document sign date :11 Jul, 2015
  • 65. www.globsynskills.com 65 <h2 style="font-family:Cooper Black;color:purple;"><u>EMPLOYEE DETAILS </u></h2> <% Employee emp = (Employee)request.getAttribute("employeeDetails"); %> <center><h2>Employee Details Page</h2></center> <table border="1" align="center"> <tr> <td colspan="2"><b>Project Details</b></td> </tr> <tr> <td>Id :</td><td><%=emp.getE_id() %></td> </tr> <tr> <td>Name :</td><td><%=emp.getE_name() %></td> </tr> <tr> <td>Age :</td><td><%=emp.getE_age() %></td> </tr> <tr> <td>Address :</td><td><%=emp.getE_address() %></td> </tr> <tr> <td>Contact:</td><td><%=emp.getE_contact() %></td> </tr> </table> <a href="GPHome.jsp">Home Page</a> </div> </body> </html> Code for logout:- Servlet:- package com.vt.project.servlet; Document sign date :11 Jul, 2015
  • 66. www.globsynskills.com 66 import java.io.IOException; import java.io.PrintWriter; import javax.servlet.RequestDispatcher; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; /** * Servlet implementation class Logout */ @WebServlet("/Logout") public class Logout extends HttpServlet { private static final long serialVersionUID = 1L; /** * @see HttpServlet#HttpServlet() */ public logout() { super(); // TODO Auto-generated constructor stub } /** * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) */ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { HttpSession session = request.getSession(false); session.invalidate(); response.setContentType("text/html"); RequestDispatcher rd=request.getRequestDispatcher("Tologout.jsp"); } } Tologout.jsp:- Document sign date :11 Jul, 2015
  • 67. www.globsynskills.com 67 <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> <%@ page import="javax.servlet.*" %> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO- 8859-1"> <title>Insert title here</title> </head> <body background="big1.jpg" > <img src="MGNREGA_Logo.gif" align="left" height="550" width="50%"> <div style="text-align:right"> <h1><font color="MidnightBlue">You are Sucessfully logged out...</font></h1> <a href="Home.jsp">Go-Back To Home Page</a> </form> </div> </body> </html> Document sign date :11 Jul, 2015
  • 68. www.globsynskills.com 68 Certificate This is to certify that Ms. MANISHA AGARWAL of Jalpaiguri Govt. Engg. College, registration number:131010110092, has successfully completed a project on M.N.R.E.G.A. PORTAL using JEE under the guidance of Mr. Bhavesh. --- --------------------------------------------------- - Bhavesh Globsyn Finishing School (a division of Globsyn Skills) Document sign date :11 Jul, 2015
  • 69. www.globsynskills.com 69 Certificate This is to certify that Ms. ANWESHA BHOWMIK of Jalpaiguri Govt. Engg. College, registration number:131010110068, has successfully completed a project on M.N.R.E.G.A. PORTAL using JEE under the guidance of Mr. Bhavesh. --- --------------------------------------------------- - Bhavesh Globsyn Finishing School (a division of Globsyn Skills) Document sign date :11 Jul, 2015
  • 70. www.globsynskills.com 70 Certificate This is to certify that Mr. ATANU DEB of Jalpaiguri Govt. Engg. College, registration number:131010110073, has successfully completed a project on M.N.R.E.G.A. PORTAL using JEE under the guidance of Mr. Bhavesh. --- --------------------------------------------------- - Bhavesh Globsyn Finishing School (a division of Globsyn Skills) Document sign date :11 Jul, 2015
  • 71. www.globsynskills.com 71 Certificate This is to certify that Ms. KRITI PAL of Jalpaiguri Govt. Engg. College, registration number:131010110016, has successfully completed a project on M.N.R.E.G.A. PORTAL using JEE under the guidance of Mr. Bhavesh. --- --------------------------------------------------- Bhavesh Globsyn Finishing School (a division of Globsyn Skills) Document sign date :11 Jul, 2015
  • 72. www.globsynskills.com 72 Certificate This is to certify that Ms. MADHUMITA DAS of Jalpaiguri Govt. Engg. College, registration number:131010110018, has successfully completed a project on M.N.R.E.G.A. PORTAL using JEE under the guidance of Mr. Bhavesh. --- --------------------------------------------------- - Bhavesh Globsyn Finishing School (a division of Globsyn Skills) Document sign date :11 Jul, 2015