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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T21:33:32+00:00 2026-06-02T21:33:32+00:00

Let’s say I’ve got two request attributes coming: fieldnames which is a list of

  • 0

Let’s say I’ve got two request attributes coming:

  1. “fieldnames” which is a list of field names. example: [“fielda”, “fieldb”]
  2. “field.fielda” which contains a snippet of html. example: an input field or something like that

In my JSP page I’ve got something like the following:

<c:forEach var="field" value="${fieldnames}">
  <c:set var="tmp" value="field.${field}"/>
  ${request.getAttribute(tmp)}
</c:forEach>

Now the problem, I can see the name of the field via the list. I can generate in a temp variable the “proper” field name. But I can’t figure out how to get the value of the referenced attribute from the request attribute map. Can this be done? I’ve tried using the request[variable] notation as well to no avail.

  • 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-02T21:33:33+00:00Added an answer on June 2, 2026 at 9:33 pm

    Assuming you have a bean like:

    public class MyBean {
       private String fielda;
       private String fieldb;
    
       public String getFielda() {
          return fielda;
       }
       public void setFielda(String fielda) {
          this.fielda = fielda;
       }
       public String getFieldb() {
          return fieldb;
       }
       public void setFieldb(String fieldb) {
          this.fieldb = fieldb;
       }
    }
    

    with code somewhere that does:

    MyBean field = new MyBean();
    field.setFielda("Message from A");
    field.setFieldb("Message from B");
    request.setAttribute("field", field);
    
    request.setAttribute("fieldnames", new String[] { 
       "fielda", "fieldb" 
    });
    

    then something like this should work:

    <c:forEach var="fn" items="${fieldnames}">
       ${requestScope.field[fn]}
    </c:forEach> 
    

    If that fails, or your code is more complex than that, you could pull out the logic in a custom tag or a custom function to do the EL evaluation. If that’s too much overhead for the situation, then maybe you could rethink your code and find another way for obtaining the same result.

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

Sidebar

Related Questions

Let's say I've got two tables: one with customer data, one with location data.
Let's say i have two tables in db: Car and Part. Car owns arbitrialy
Let's say I have a structure named vertex with a method that adds two
Let's say I have two tables orgs and states orgs is (o_ID, state_abbr) and
Let's say I have the following text: (example) <table> <tr> <td> <span>col1</span> </td> <td>col2</td>
Let's say I'm making a tool to help epicureans keep track of which delicacies
Let's say you have a class called Customer, which contains the following fields: UserName
Let's say we have a simple function defined in a pseudo language. List<Numbers> SortNumbers(List<Numbers>
Let's say I have a dataset, which can be neatly classified using weka's J48
Let say I have two UIViews: View1: - bounds: 0, 0, 20, 20 -

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.