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 8297393
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T15:24:16+00:00 2026-06-08T15:24:16+00:00

I have a form class where I have a String array. I am setting

  • 0

I have a form class where I have a String array. I am setting the value for the string array. I need to print this array values one by one in a JSP page. The code I have written is:

paxList = getPaxList(id);

List<String> passengerName = new ArrayList<String>();
List<Double> passengerAge = new ArrayList<Double>();

for(int i=0; i < paxList.size(); i++){
    passengerName.add(paxList.get(i).getPassengerName());
    passengerAge.add(paxList.get(i).getPassengerAge());
}

bookingsForm.setPassengerName(passengerName.toArray(new String[paxList.size()]));
bookingsForm.setPassengerAge(passengerAge.toArray(new Double[paxList.size()]));

Now I need to print the values from the PassengerName.

I tried like this in my JSP page

<logic:iterate id="currentPassName" property="passengerName" >
    <bean:write name="currentPassName" />
</logic:iterate>

but this is not working for me. can someone guide me.

  • 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-08T15:24:19+00:00Added an answer on June 8, 2026 at 3:24 pm

    You shouldn’t split your list of passengers into two lists of name and age. That’s what makes things difficult. Just store paxList into your form directly.

    Once this is done, do yourself a favor and use the JSTL rather than the deprecated struts logic and bean tags:

    <c:forEach items="${bookingsForm.paxList}" var="passenger">
        Passenger <c:out value="${passenger.name}" is aged ${passenger.age}<br/>
    </c:forEach>
    

    To explain why it doesn’t work as is:

    <logic:iterate id="passRecord" property="passengerName" >
        <bean:write name="passengerName" property="passRecord" />
    </logic:iterate>
    

    The above iterates through the elements of the form’s passengerName array (which you should name passengerNames, since there are several of them), and defines a page attribute named passRecord that you must use inside the loop.

    Since passengerName is a String array, passRecord is a String. And inside the loop you’re trying to access the property passRecord of passengerName. There is no method getPassRecord() in String[]. The passenger name is stored in passRecord. You just need to write it. With properly named variables, it would be much clearer:

    <logic:iterate id="currentPassengerName" property="passengerNames" >
        <bean:write name="currentPassengerName" />
    </logic:iterate>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Problem 1. I have this class: public class ContactGroups { // Form an array
I have a form builder class which inherits from AbstractType and I need to
I have a form that looks like this: class SampleForm(forms.Form): text = forms.CharField(max_length=100) In
I have this form: <%= form_tag posts_path, :method => :get, :class => search_nav do
Suppose we have the Java code: Object arr = Array.newInstance(Array.class, 5); Would that run?
I have written this code for a search page in PHP and I would
Ok I am confused by this, I have: a int variable a string array
I have classes like this public class someList { public string strOne {get; set;}
I have a simple class like this: public class myClass { public List<string> innerList;
I have a form in spring mvc 2 having command class Class1 I want

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.