Hackforge Academy

Category: java

Request parameters and form data

Published on 30 Sep 2026

Explanation

Request parameters are values sent by the client as part of the URL query string or HTML form data.

Code:

GET /users?id=101

id = 101

Explanation

Use getParameter() to retrieve a single request parameter.

Code:

String name = request.getParameter("name");
System.out.println(name);

Explanation

Use getParameterValues() when multiple values can be submitted with the same parameter name.

Code:

String[] skills =
    request.getParameterValues("skill");

for (String skill : skills) {
    System.out.println(skill);
}

Explanation

HTML form fields are submitted to the servlet using their name attributes.

Code:

<form action="register" method="post">
    <input type="text" name="username">
    <input type="email" name="email">
    <button type="submit">Register</button>
</form>

Explanation

The servlet can read the submitted form data and process it.

Code:

protected void doPost(HttpServletRequest request,
                      HttpServletResponse response)
                      throws IOException {

    String username = request.getParameter("username");
    String email = request.getParameter("email");

    response.getWriter()
            .println(username + " - " + email);
}

πŸš€ Learn Spring Boot with real-world projects

πŸ’‘ Build REST APIs step by step

🧠 Improve backend development skills

🎯 Get career-ready practical training

Join Our Free WhatsApp Community

Direct access to niche-specific mentors and peers on WhatsApp.

🐍

Python Community

Discuss Django, FastAPI, AI integration, and automation scripts with 15k+ developers.

Join Python Community
βš›οΈ

React Community

Master Next.js, Framer Motion, and State Management. Share your latest UI components.

Join React Community
β˜•

Java Community

Deep dives into Spring Boot, Microservices architecture, and high-performance backend ops.

Join Java Community