Lecture 19: Handling HTTP GET & POST Requests

BMC201 - Web Technology

Mr. Prashant Kumar Nag

2026-02-25

Lecture 19

Handling HTTP GET & POST Requests

Week 5 | Unit III: Web App Development (Servlets + JSP)
BMC201 - Web Technology
Mr. Prashant Kumar Nag, Assistant Professor

Learning Objectives


  • Differentiate GET and POST semantics
  • Handle request parameters in servlet methods
  • Apply server-side input validation

Prerequisites


  • Java basics: classes, methods, objects, and exception handling
  • HTTP request-response fundamentals from Unit I/II web context
  • Revision of Lecture 18 before moving into Handling HTTP GET & POST Requests

Syllabus Mapping


  • Unit III topic focus: Handling HTTP GET & POST Requests
  • CO alignment: implementation understanding + architecture reasoning
  • Assessment alignment: short definitions + long implementation/design questions

Agenda


  • 5-minute recap from previous lecture
  • Concept deep dive: Handling HTTP GET & POST Requests
  • Code/configuration walkthrough and output analysis
  • Debug checklist and exam-oriented summary

Introduction


HTTP method choice impacts semantics, security, and behavior.

Think About It


Should credentials be visible in URL query strings?

GET vs POST


GET: retrieval/query string, POST: submission/request body

Code Walkthrough


protected void doGet(HttpServletRequest req, HttpServletResponse res) throws IOException {
  String q = req.getParameter("q");
  res.getWriter().println("Search: " + q);
}

protected void doPost(HttpServletRequest req, HttpServletResponse res) throws IOException {
  String user = req.getParameter("username");
  res.getWriter().println("Posted user: " + user);
}

Memory Booster


Syllabus memory points for Handling HTTP GET & POST Requests:

  • Core recall: doGet() and doPost()
  • Exam compare: GET parameterized retrieval vs POST state-changing submission
  • Practical anchor: Create one GET and one POST endpoint and test both

Live Demo


Live implementation for Handling HTTP GET & POST Requests:

?? Open Demo: Lecture 19 - Handling HTTP GET & POST Requests

Demo checklist: - implement the key flow for this lecture - verify expected output for one success case - trigger one failure case and explain the fix

Resources & References


Structured Debug Checklist


  1. verify the primary API usage for Handling HTTP GET & POST Requests is correct (imports, method names, config)
  2. check request/bean/session flow and object lifecycle assumptions
  3. inspect server logs for the first exception (not just the final symptom)
  4. reproduce one failing case and one passing case before finalizing fixes

Exam Preparation Questions: Short


  • Define Handling HTTP GET & POST Requests with one practical use case.
  • Write/identify the key API or construct: doGet() and doPost().
  • Differentiate: GET parameterized retrieval vs POST state-changing submission.
  • Mention one common implementation error and correction.

Exam Preparation Questions: Long


  • Explain Handling HTTP GET & POST Requests with architecture/flow and implementation steps.
  • Write a structured answer comparing two approaches used in this topic.
  • Discuss debugging strategy for this topic with likely failure points.

Practice Task


  • Implement: Create one GET and one POST endpoint and test both.
  • Add console/log output to validate flow step-by-step.
  • Document one bug you encountered and the exact fix.

Checklist


Can you:

  • explain Handling HTTP GET & POST Requests in your own words?
  • implement a basic example end-to-end?
  • identify and fix one common runtime issue?

Next Lecture


  • Topic: Lecture 20 - Redirecting Requests & Request Dispatching
  • Preparation required: revise this lecture summary and code walkthrough

Questions?

Next: Lecture 20