Skip to content

πŸ“¦ Employer-Worker-Registration-System. A system where: Employers and Workers can register and log in. Employers can post jobs. Workers can view jobs and apply. πŸš€

License

Notifications You must be signed in to change notification settings

mscbuild/Employer-Worker-Registration-System

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

58 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Employer-Worker-Registration-System

βœ… Project Overview.

🎯 Goal: A system where:

Employers and Workers can register and log in.

Employers can post jobs.

Workers can view jobs and apply.

πŸ“ Project Structure

EmployerWorkerSystem/
β”œβ”€β”€ πŸ“ src/
β”‚   └── πŸ“ com.system/
β”‚       β”œβ”€β”€ πŸ“ controllers/
β”‚       β”‚   β”œβ”€β”€ LoginServlet.java
β”‚       β”‚   β”œβ”€β”€ LogoutServlet.java
β”‚       β”‚   β”œβ”€β”€ RegisterServlet.java
β”‚       β”‚   β”œβ”€β”€ ApplyJobServlet.java
β”‚       β”‚   β”œβ”€β”€ PostJobServlet.java
β”‚       β”‚   β”œβ”€β”€ UpdateStatusServlet.java
β”‚       β”‚   └── UploadResumeServlet.java (optional)
β”‚       β”œβ”€β”€ πŸ“ utils/
β”‚       β”‚   └── DBUtil.java
β”‚       β”‚   └── EmailUtility.java
β”‚       └── πŸ“ models/
β”‚           └── User.java
β”‚           └── Job.java
β”‚           └── Application.java
β”‚
β”œβ”€β”€ πŸ“ WebContent/  (or webapp/)
β”‚   β”œβ”€β”€ πŸ“ css/
β”‚   β”‚   └── style.css
β”‚   β”œβ”€β”€ πŸ“ js/
β”‚   β”‚   └── app.js
β”‚   β”œβ”€β”€ πŸ“ uploads/        <-- Uploaded images/resumes go here
β”‚   β”œβ”€β”€ πŸ“ jsp/
β”‚   β”‚   β”œβ”€β”€ login.jsp
β”‚   β”‚   β”œβ”€β”€ register.jsp
β”‚   β”‚   β”œβ”€β”€ employer_dashboard.jsp
β”‚   β”‚   β”œβ”€β”€ worker_dashboard.jsp
β”‚   β”‚   β”œβ”€β”€ post_job.jsp
β”‚   β”‚   β”œβ”€β”€ available_jobs.jsp
β”‚   β”‚   β”œβ”€β”€ manage_applicants.jsp
β”‚   β”‚   β”œβ”€β”€ worker_applied_jobs.jsp
β”‚   β”‚   β”œβ”€β”€ profile.jsp
β”‚   β”‚   └── error.jsp
β”‚   └── index.jsp
β”‚
β”œβ”€β”€ πŸ“ META-INF/
β”œβ”€β”€ πŸ“ WEB-INF/
β”‚   β”œβ”€β”€ web.xml
β”‚   └── lib/ (if not using Maven: put JDBC, JavaMail JARs here)
β”‚
β”œβ”€β”€ πŸ“„ pom.xml (if using Maven)
└── πŸ“„ README.md

 

🧾 Database Tables Example (MySQL/PostgreSQL).

-- User Table (Employer or Worker)
CREATE TABLE users (
    id INT AUTO_INCREMENT PRIMARY KEY,
    username VARCHAR(100),
    email VARCHAR(100),
    password VARCHAR(100),
    role ENUM('employer', 'worker')
);

-- Jobs (Posted by Employers)
CREATE TABLE jobs (
    id INT AUTO_INCREMENT PRIMARY KEY,
    title VARCHAR(255),
    description TEXT,
    employer_id INT,
    FOREIGN KEY (employer_id) REFERENCES users(id)
);

-- Applications (Submitted by Workers)
CREATE TABLE applications (
    id INT AUTO_INCREMENT PRIMARY KEY,
    job_id INT,
    worker_id INT,
    FOREIGN KEY (job_id) REFERENCES jobs(id),
    FOREIGN KEY (worker_id) REFERENCES users(id)
);

πŸ”§ Core Servlets.

RegisterServlet.java – Handles user registration.

LoginServlet.java – Handles authentication and session.

PostJobServlet.java – Employer posts a job.

ApplyJobServlet.java – Worker applies for job.

🌐 Example: Registration Form (HTML/JSP)

<form action="RegisterServlet" method="post">
  <input type="text" name="username" placeholder="Username" required><br>
  <input type="email" name="email" placeholder="Email" required><br>
  <input type="password" name="password" placeholder="Password" required><br>
  <select name="role">
    <option value="employer">Employer</option>
    <option value="worker">Worker</option>
  </select><br>
  <button type="submit">Register</button>
</form>

πŸ“Œ Tips.

Store passwords hashed (e.g., using SHA-256).

Use sessions to manage login state.

Validate inputs both on client (JS) and server (Servlet).

Show different dashboards for employer vs. worker.

πŸ”„ After Form Submission.

The form will send data to your RegisterServlet, where you'll handle:

Validating input

Inserting user into the database

Redirecting to login or dashboard

🧩 Next Steps.

Make sure your web.xml or annotations register this servlet.

Test the form and ensure the data is inserted into the database.

Add a login.jsp and LoginServlet.java next for authentication.

πŸ” Optional: Secure with Session Filters.

🧩 How to Use.

In your dashboard pages (e.g. employer_dashboard.jsp, worker_dashboard.jsp), include a logout link:

<a href="../LogoutServlet">Logout</a>

πŸ›‘οΈ Optional: Session Check Snippet in JSP.

To protect pages from unauthorized access, add this at the top of protected JSPs:

<%
  String user = (String) session.getAttribute("username");
  if (user == null) {
      response.sendRedirect("../login.jsp");
  }
%>

🧩 Let's implement the Job Posting feature for employers in your system.

This feature will include:

A JSP form (post_job.jsp) to enter job details

A Servlet (PostJobServlet.java) to handle form submission

A MySQL table to store job posts.

βœ… 1. Create the jobs Table.

Make sure your database has this table:

CREATE TABLE jobs (
    id INT AUTO_INCREMENT PRIMARY KEY,
    title VARCHAR(255) NOT NULL,
    description TEXT,
    employer_id INT NOT NULL,
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    FOREIGN KEY (employer_id) REFERENCES users(id)
);

βœ… 2. JSP Form: βœ… 3. Servlet:

πŸ”§ IMPORTANT – Track userId on Login. Update your LoginServlet to store the user's ID:

int userId = rs.getInt("id");
session.setAttribute("userId", userId);

🧩 Overview,

This will include:

A job listing JSP for workers

A button/form to apply for a job

A new database table to store applications

An ApplyJobServlet to handle applications

βœ… 1. Create job_applications Table.

In your MySQL database:

CREATE TABLE job_applications (
    id INT AUTO_INCREMENT PRIMARY KEY,
    job_id INT NOT NULL,
    worker_id INT NOT NULL,
    applied_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    FOREIGN KEY (job_id) REFERENCES jobs(id),
    FOREIGN KEY (worker_id) REFERENCES users(id)
);

βœ… 2. JSP Page: job_list.jsp.

This lists jobs and shows an β€œApply” button for each job. Add a check so only workers can access it.

βœ… 3. Servlet: ApplyJobServlet.java

βœ… 4. Add Link to Job List (from dashboard).

On worker_dashboard.jsp, link to the job listing:

<a href="job_list.jsp">Browse Jobs</a>

🧩 Feature Overview.

JSP page: view_applicants.jsp

Fetch applicants for jobs posted by the logged-in employer

Display job title and list of workers who applied

βœ… 1. JSP Page.

βœ… 2. Add Link in employer_dashboard.jsp:

<a href="view_applicants.jsp">View Applicants</a>

🧩 What's Included:

Update the job_applications table to include a status field

Modify the ApplyJobServlet to set default status

Create a JSP page for employers to update application status

Create a JSP page for workers to view their applied jobs with status

βœ… 1. Update job_applications Table.

Run this SQL to add a status column:

ALTER TABLE job_applications ADD COLUMN status VARCHAR(20) DEFAULT 'Pending';

βœ… 2. Modify ApplyJobServlet.java

Add this line when inserting application:

String sql = "INSERT INTO job_applications (job_id, worker_id, status) VALUES (?, ?, 'Pending')";

βœ… 3. JSP: manage_applicants.jsp (Employer View).

βœ… 4. UpdateStatusServlet.java.

βœ… 5. worker_applied_jobs.jsp – Worker View,

βœ… 6. Add Links in Dashboards.

In employer_dashboard.jsp :

<a href="manage_applicants.jsp">Manage Application Status</a>

*In worker_dashboard.jsp :

<a href="worker_applied_jobs.jsp">My Applications</a>

🧩 Goal.

When an employer changes the status of an application, the worker gets an automated email notification.

βœ… Steps:

Configure JavaMail in your project

Update UpdateStatusServlet to send an email after updating

Create an EmailUtility class for reusable mail sending

βœ… 1. Add JavaMail Dependency.

If using Maven, add this to pom.xml:

If not using Maven, download javax.mail jar and add it to your project’s lib folder.

βœ… 2. EmailUtility.java (Utility Class).

βœ… 3. Modify UpdateStatusServlet.java .

After updating status in DB, fetch worker email and send email:

βœ… Key Features Included.

User Registration & Login: Separate flows for employers and workers.

Job Posting: Employers can post job listings.

Job Application: Workers can apply to jobs.

Application Status Management: Employers can update application statuses; workers can view them.

Image Upload: Users can upload profile images during registration.

Email Notifications: Workers receive emails upon status updates.

πŸš€ Getting Started.

Database Setup:

Create a MySQL database named employer_worker_system.

Execute the provided schema.sql script to create necessary tables.

Configure Database Connection:

Update DBUtil.java with your database URL, username, and password.

Build and Deploy:

If using Maven, run mvn clean install.

Deploy the WAR file to your servlet container (e.g., Apache Tomcat).

Access the Application:

Navigate to http://localhost:8080/EmployerWorkerSystem/ in your browser.

πŸ“¦ The Project Template

About

πŸ“¦ Employer-Worker-Registration-System. A system where: Employers and Workers can register and log in. Employers can post jobs. Workers can view jobs and apply. πŸš€

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages