-
Notifications
You must be signed in to change notification settings - Fork 0
Topic 4: Web Component ‐ JSP
Zhamri Che Ani edited this page Apr 10, 2026
·
2 revisions
To enable students to develop dynamic web pages using JSP and integrate them with Servlets in an MVC-based web application.
Students should be able to:
- Explain the role of JSP in Java web applications
- Describe how JSP is processed by the server
- Use JSP elements (directives, expressions, scriptlets)
- Handle input data using JSP
- Forward requests between JSP and Servlet
- Integrate JSP as the View component in MVC
- Introduction to JSP
- What is JSP
- JSP lifecycle
- JSP Processing
- Translation to Servlet
- Compilation and execution
- JSP Elements
- Directives (
<%@ %>) - Expressions (
<%= %>) - Scriptlets (
<% %>)
- Directives (
- Predefined Variables (Implicit Objects)
- request, response, session, out
- Associating Properties with Input Parameters
- Using form data in JSP
- Forwarding Requests
- RequestDispatcher
- Forward vs Redirect
Activity: Student Registration System (Servlet + JSP Integration)
Students are required to:
- Create JSP Page (View)
- Create result.jsp
- Display student data using:
Name: ${name}
Email: ${email}
Program: ${program}
- Modify Servlet (Controller). In RegisterServlet:
- Retrieve form data
- Store data using request attributes:
request.setAttribute("name", name);
Forward to JSP:
RequestDispatcher rd = request.getRequestDispatcher("result.jsp");
rd.forward(request, response);
-
Display Data in JSP Use JSP expressions or EL:
- <%= request.getAttribute("name") %>
- or ${name} (preferred)
-
Add Navigation Flow
- Form → Servlet → JSP
- Show confirmation message:
Registration Successful!
Welcome, Ali!
- (Optional Enhancement)
- Create
login.jspanddashboard.jsp - Use session to maintain user login
- Create
Students should produce:
- JSP page (result.jsp)
- Updated Servlet
- Working MVC flow:
HTML Form → Servlet → JSP
- Oracle JSP Documentation https://jakarta.ee/specifications/pages/
- JSP Tutorial (W3Schools) https://www.w3schools.in/jsp/tutorials/
- JSP Tutorial (tutorialspoint) https://www.tutorialspoint.com/jsp/index.htm
- MVC Architecture in Java Web
- JSP Expression Language (EL) Guide