Project 4: Overview
In this project, you’ll build a Java web application that follows MVC and connects to a database (JDBC).
You’ll complete Project 4 in four stages:
- Plan → Review new requirements, create a sequence diagram of the flow of the Add Employee and Search Employee process.
- Build → Implement servlets, JavaBeans, JSP + EL, JDBC, properties-driven config, and a working Add and Search feature.
- Submit & Reflect → Capture required screenshots, push to GitHub, and write your reflection.
- Code Review → Walk through your web app (controller→model→view) and DB integration.
Part 1 – Plan
-
Review the full web-application + database requirements:
- Review and understand the database schema
- Identify your the model, view, and controllers for the application
-
Document the flow of the Add Employee and Search Employee process
- Use a sequence diagram), flowchart, or another diagram to illustrate how each component of the application interacts with each other during both actions (add and search).
📦 Deliverables: Flow diagram screenshot, GitHub issue “Project 4 plan ready for review.”
Heads-up: You must get plan approval before heavy coding begins. If large portions of code are present before your plan is reviewed, the plan may be marked Not Yet.
Part 2 – Build
Suggested Coding Process
This is a large project, with many files. It's important that you go into the coding process with a plan to break down the project into small parts, testing as you go. There are many ways to break the project into smaller part, this is just one suggestion!
-
Create the jsp files in your public_html directory
- Use your design template on each page.
- Add an appropriate
h1heading to each page.
File Purpose employeeAdd.jsp Add employee form employeeSearch.jsp Search employee form employeeSearchResults.jsp Search employee results index.jsp public_html -
Add the following files to the java112/employee package.
- Add the package statement, class JavaDoc, and empty constructor to each java file for a start.
- Add a constructor that accepts properties as parameter for the EmployeeDirectory
File Purpose Employee.java Javabean for employee Search.java Javabean for search EmployeeDirectory Data Access Object (DAO) -
Add the following file to the java112/project4 package.
- Add the package statement, class JavaDoc, and empty constructor to each java file for a start.
- Add imports required for a servlet
File Purpose ApplicationStartup.java initialization servlet EmployeeAddDisplay Forwards to add employee jsp EmployeeAdd.java Add employee servlet EmployeeSearchDisplay.java Forwards to search employee jsp EmployeeSearch.java Search employee servlet -
Create the project4.properties file
Use your name and email.
author=Kari Schumacher email=kkschumacher@madisoncollege.edu course.title=Advanced Java course.meeting=online project=4 driver=org.mariadb.jdbc.Driver url=jdbc:mariadb://localhost/student?serverTimezone=America/Chicago username=student password=student -
Add ApplicationStartup Logic
- Add logic into the ApplicationStartup class
- Load your properties using the PropertiesLoader interface and store in the servlet context
- Create an instance of the EmployeeDirectory and store in the servlet context
Test
Add a temporary log or print statement to confirm properties loaded successfully.
-
Add the fields for the Employee JavaBean along with getters/setters and toString method.
-
Add the fields for the Search JavaBean along with getters/setters and toString method.
-
Build the Add Employee flow with NO LOGIC
Start with the add employee process. This flow is slightly easier than the Search Employee process.
Create the files necessary for the Add Employee flow and makes sure the flow from file to file works before adding any logic.
File Link Action index.jsp links to the EmployeeAddDisplay EmployeeAddDisplay just forwards to employeeAdd.jsp employeeAdd.jsp form action to EmployeeAdd servlet with POST method EmployeeAdd redirects back to the employeeAdd.jsp employeeAdd.jsp none Test
Validate the above files connect correctly.
-
Build the Search Employee flow with NO LOGIC
Create the files necessary for the Search Employee flow and makes sure the flow from file to file works before adding any logic.
File Link Action index.jsp links to the EmployeeSearchDisplay EmployeeSearchDisplay just forwards to employeeSearch.jsp employeeSearch.jsp form action to EmployeeSearch servlet with a GET method EmployeeSearch forwards to the employeeSearchResults.jsp employeeSearchResults.jsp none Test
Validate the above files connect correctly.
-
Add in the logic, testing as you go.
Here are things to test as you build in logic
- Test that you are getting a valid database connection.
- Test that you are building a valid sql statement/insert
- Test that you are successfully performing a search
- Test that you are successfully performing an insert
- Test that your success/failure messages on the JSP appear and disappear appropriately.
What else? There are MANY things you could validate as you go!
📦 Deliverables: Running MVC web app with working DB integration; properties-driven config; correct pages and flows; complete JavaDoc where required.
Part 3 - Submit & Reflect
Go to Project 4 Submission & Reflection
- Screenshots: Save required images under
screenshots/project-4 - Push to GitHub: Stage → commit → push.
- Open an issue: “Project 4 ready for review” and complete the reflection prompts.
- Optional: If doing the live review later, you can schedule or record now.
Deliverables: Screenshots, GitHub repo updated, reflection completed.
Part 4 – Code Review
- Walkthrough (~10 min):
- Demonstrate the Add Employee process
- Demonstrate the Search Employee process by searching for the employee added above.
- Be ready to answer: debugging example, best practice, programming principle, OOP concept, and collections usage.
Deliverables: Code review completed, notes saved, corrections made if needed.
You need to complete 2 code reviews to pass the course. If you are in an in-person class, code-reviews can be completed during class time.
Pro Tips
- Use your diagram as a roadmap. Your sequence diagram + servlet/JSP flow should guide every line you write.
- Start with ApplicationStartup. If the app can’t start correctly, nothing else will work. Get properties + EmployeeDirectory loading first.
- Think MVC.
- Controllers = Servlets
- Model = EmployeeDirectory + JavaBeans
- View = JSP
- Reuse shared objects. Always grab the EmployeeDirectory from the ServletContext; don’t recreate it.
- Keep database code in the EmployeeDirectory. If you catch yourself writing SQL in a servlet; you’ve taken a wrong turn.
- Use GET and POST properly.
- Search form → GET
- Add Employee form → POST
-
Test the flow manually.
- Can you load the add form?
- Can you submit it?
- Does the new employee appear in the database?
- Does search return correct results?
-
Add friendly messages. Show clear success/failure feedback after adding employees.
- Log errors clearly. Print a helpful message before the stack trace.
- Commit often. Each servlet, JSP, or milestone should have its own commit.