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

  • SEARCH
  • Home
  • 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 8972425
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T18:12:56+00:00 2026-06-15T18:12:56+00:00

Here is a simplified (NOT real world) example. Suppose there is a domain model

  • 0

Here is a simplified (NOT real world) example. Suppose there is a domain model – a class Movie, which has a List of actors. A class Actor has three fields (name, birthDate, rolesNumber). The following code is an illustration of this scenario:

Movie.java

public class Movie {

    // some fields

    private List<Actor> actors;

    // getters and setters
}

Actor.java

public class Actor {

    private String name;

    private Date birthDate;

    private int rolesNumber;

    // getters and setters
} 

There is also a JSP page where we output in a loop the information about every actor that plays in a concrete movie and the user can update the corresponding text field values and submit changes to a servlet:

actorsUpdate.jsp

...
<c:forEach items="${movie.actors}" var="actor">
    <table>
        <tr>
            <th>Name</th>
            <td><input type="text" value="${actor.name}" /></td>
        </tr>
        <tr>
            <th>Birth Date</th>
            <td><input type="text" value="${actor.birthDate}" /></td>
        </tr>
        <tr>
            <th>Number of Previous Roles</th>
            <td><input type="text" value="${actor.rolesNumber}" /></td>
        </tr>
    </table>
    <hr />
</c:forEach>
...

It is known that in order to retrieve text fields in a servlet, one can use ServletRequest’s methods like getParameter() or getParameterValues() etc. But how to retrieve the updated input fields as a List of objects (so that every three related values were grouped)?

If it were Spring project we could use Spring’s <form:form modelAttribute="modelName">
tag and have a backing object defined in the modelAttribute. But how about pure JSP/Servlet project?

Possible solution

One of the possible solutions is to assign names in the “name” attribute of the text inputs and append varStatus.index, like this:

<c:forEach items="${movie.actors}" var="actor" varStatus="counter">
    <table>
        <tr>
            <th>Name</th>
            <td><input type="text" name="name${counter.index}" value="${actor.name}" /></td>
        </tr>
        ...
    </table>
    <hr />
</c:forEach>

So this index would allow us to identify values related to ONE object. And we could also generate some hidden input field where we could store a loop count (a number of actors), and then in a servlet we could retrieve the values related to one object like this:

List<Actor> actors= new ArrayList<Actor>();
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
for (int i = 0; i < count; i++) {
    String name= request.getParamater("name" + i);
    Date birthDate = dateFormat.parse(request.getParamater("birthDate" + i));
    int rolesNumber = Integer.parseInt(request.getParamater("rolesNumber" + i));

    Actor actor = new Actor(name, birthDate, rolesNumber);
    actors.add(actor);
}

My questions are:

  1. Is there another, more elegant and effective way of passing the updated text field values to a servlet as a List of objects?

  2. Is there any solution similar or equivalent to that of the Spring’s <form:form> tag in a world of pure JSP/JSTL/EL/Servlets?


UPDATE

Looks like nobody knows the answer to the above questions. The accepted answer is not exactly what I asked for (see my comments to it).

There seems to be no equivalent of Spring’s <form:form modelAttribute> tag or something similar in the world of pure Servlets/JSP.

Well, full Java EE, or Spring Framework, Apache Struts or another powerful web application framework to the rescue!

  • 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-06-15T18:12:57+00:00Added an answer on June 15, 2026 at 6:12 pm

    you can use the same name(revisionNumber) for all the inputs and use

    String[] revisionNumber = request.getParamaterValues("revisionNumber") to get an array.

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

Sidebar

Related Questions

I want to list all users with their corropsonding user class. Here are simplified
Here is the simplified version of my question. There are two tables one has
Here is a simplified version of what I have (not working): prog.h: ... const
Here is simplified version of my requirement I have a java class say Processor
I look at example of dropdown menu here . Here is simplified jsfiddle example.
Here is simplified SQL of my tables, which is converted to LINQ to SQL
Here is a very simplified program which reproduces the issue I faced in the
I'm not sure if I understand template method pattern correctly. Here is my simplified
The code posted here is 'example' code, it's not production code. I've done this
here is a very simplified example of what happened jQuery(.resultAction).each(makeItso); function makeItso() { //code

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.