Notes
Election Management System Overview
- Web-based voting application with user authentication
- Components: Login, Candidate List, Voting, Results
- Flow: Signup → Login → Vote → Logout
- Admin features: Candidate management (CRUD operations)
Inter-Servlet Communication
Navigation Methods
- Redirection (
resp.sendRedirect()
)
- Client receives 302 status code
- Browser makes new request to different URL
- URL changes in browser
- Can navigate to any page (internal/external)
- Slower (two HTTP requests)
- Useful after POST requests (PRG pattern)
- Forward (
RequestDispatcher.forward()
)
- Server-side navigation
- Same request object passed to next servlet
- URL unchanged in browser
- Only within same web application
- Faster (single request)
- Final response generated by target page
- Include (
RequestDispatcher.include()
)
- Includes response from another servlet
- Same request object shared
- URL unchanged in browser
- Only within same web application
- Response sent by first page
PRG Pattern (Post-Redirect-Get)
- Prevents duplicate form submissions on refresh
- After POST request, redirect to GET request
- Avoids data being posted twice to database
State Management
Overview
- State Management: Maintaining client information across requests
- Client-side: Less secure, reduces server load, increases network traffic
- Server-side: More secure, increases server memory usage