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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T17:17:39+00:00 2026-06-06T17:17:39+00:00

I have to be able to store data in a new object, that I

  • 0

I have to be able to store data in a new object, that I am getting from a complex object where each item is held in a List.

The hierarchy is the following:
1) libraryId (Library)
2) bookId (book)
3) pageId (page)
4) wordId (word)

  • A library can have zero to many books. Each book is unique and can have zero to many pageId’s, if there is a page, each pageId can have zero to many wordId’s.

I have the data, but I need to cycle through each item and put into an object – ArrayList or similar – so I can pass off to another class, which is expecting a List. In the next class, the data is to be presented in a JSP data table.

I have the following classed to do this:

class Library{ 
  int libraryId; 
  ArrayList<Book> books; 
} 

class Book { 
  int bookId; 
  ArrayList<Page> pages; 
} 

class Page { 
  int pageId; 
  ArrayList<Word> words; 
} 

class Word { 
  int wordId; 
} 

I have started to do it like this:

Book book = new Book(); // create Book object 
ArrayList<Page> pages = new ArrayList<Page>; 
pages.add(new Page()); // add first page 
pages.add(new Page()); // add next page 
book.setPages(pages); // set reference to pages for book

I have tried this.I am not sure I have it working correctly. This is how i have done it, based on the above answer. I the the same classes etc.

I have the following data example:

1 Book, which has 1 page, that page has 8 words. I have another book, which has 2 pages, each page has 6 words. I hope this makes sense.

Based on the above example, how to do I write this code, and how to I then retrieve the data back out too? The aim is that I pass this to a JSP, then retieve this out into a table using JSTL . Any help with this, to retrieve this data would also be helpful.

  • 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-06T17:17:41+00:00Added an answer on June 6, 2026 at 5:17 pm

    This really depends on your framework. Are you are a glutton for punishment and using straight JSP, if so, take a look at <jsp:useBean> or use a scriptlet (ugh…) to populate the “book” variable.

    Otherwise, it will be very framework dependent. Something like spring would be:

    @Controller
    public class MyController {
      @RequestMapping(...)
      public ModelAndView processRequest(HttpServletRequest request, 
            HttpServletResponse response) {
          Map<String, Object> model = new HashMap<String, Object>();
          Book book = ...;
          model.put("book", book);
          return new ModelAndView("viewbook", model);
      }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have to be able to store data in a new object, that I
I have classes that store data, and methods to go get data for individual
I have a tabel containing a column named parent which is able to store
I want to be able to have a Stored Procedure that can only be
I have been able to design my layout so that it has 2 columns
What I have been able to grasp from reading the source and documentation from
I have this excel file which I have been able to write the data
I am creating an object server-side which is to have all of the data
I need to utilize the Cache object in ASP.NET to store some data with
I have a desktop (winforms) application that uses a Firebird database as a data

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.