Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6885459
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T05:38:15+00:00 2026-05-27T05:38:15+00:00

Let’s assume I have a form with these fields (HTML) <input type=text name=user[name] value=name/>

  • 0

Let’s assume I have a form with these fields (HTML)

<input type="text" name="user[name]" value="name"/>
<input type="text" name="user[email]" value="email"/>
<input type="text" name="user[age]" value="age"/>

how do I get this information inside a java Servlet?

In php it is just

      $_POST["user"]["name"]

or

      $_GET["user"]["name"]

I am not referring at simple field like

      <input type="text" name="user" value="jimmy"/>

I am referring at retrieving arrays of data, like in the case of a set of checkboxes or a multiple select.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T05:38:15+00:00Added an answer on May 27, 2026 at 5:38 am

    One thing to keep in mind, is that the brackets in the field names have no special meaning and are simply part of the name, so you’d have to include them when using ServletRequest::getParameter:

    request.getParameter("user[name]");
    

    It’s only PHP (or another additional framework), that “automagically” treats names with brackets as an array (or in case of Java more likely a Map).

    If you what such a map and you are not using a such framework you’d need to create it yourself, for example, by looping over ServletRequest::getParameterNames.

    Example:

    public static Map<String, String> getParameterMap(ServletRequest request, String mapName) {
    
      Map<String, String> result = new HashMap<String, String>();     
    
      Enumeration<String> names = request.getParameterNames();
      while (names.hasMoreElements()) { 
        String name = names.getNextElement();
        if (name.startsWith(mapName + "[") && name.endsWith("]")) {
          result.put(name.substring(mapName.length()+1, name.length() - 2), request.getParameter(name));
        }
      }
    
      return result;
    }
    

    This is just a quick (untested) example. It doesn’t support multiple level maps (user[name][last]) nor multiple values for one name (which need getParameterValues).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let say I have some code HTML code: <ul> <li> <h1>Title 1</h1> <p>Text 1</p>
Let's say you create a wizard in an HTML form. One button goes back,
Let's say you have a class called Customer, which contains the following fields: UserName
Let's say I have the string: hello world; some random text; foo; How could
Let's suppose I have this piece of code. foreach(string value in myList) { string
Let's imagine I have a Java class of the type: public class MyClass {
Let's say I have some text as follows: do this, do that, then this,
Let's say I have many items with click event (all have same element name
Let's assume, you have the xml below. The goal is to group by FirstName
Let's say I have this MySQL table: OK.. see the type field? Type 0

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.