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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T15:47:09+00:00 2026-05-25T15:47:09+00:00

i just started to learn struts(+spring) MVC, and I could use some explanation of

  • 0

i just started to learn struts(+spring) MVC, and I could use some explanation of this situation :

i am using Struts Tiles for my presentation layer and i want to display some data from database in few tiles that with main content tile will form complete page. I can’t figure out proper way of doing this, that fits mvc pattern/best practices.

The content of those tiles is fetched form database, its not based on user input, e.g. tile that lists few latests products added to shop etc.

What i did:
i have created class ‘A’ with static method that queries database and returns list of few latests products, and in jsp of this tile i have just put scriptlet like:
<% for each item in A.GetLastestProducts(); dispaly data %>

but i have been told thats bad way of doing this

Can someone explain me how to handle this situation properly, like “create class that will query your database, than create blach that will blach blach, then in your tile jsp blach blach”

thanks

  • 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-25T15:47:09+00:00Added an answer on May 25, 2026 at 3:47 pm

    If you’re using struts, I would suggest leveraging the struts architecture for your JSP. I would probably structure it similar to this:

    public class MyStutsAction extends ActionSupport implements preparable{
    
        private List<MyNewProducts> newProducts;
    
        @Override
        public void prepare() throws Exception {
            if(products == null){
                products = MyNewProductsDAO.getProductList();
            }
        }
    
        //Struts action stuff
    
        public List<MyNewProducts> getNewProducts(){
            return newProducts;
        }
    
        public setNewProducts(List<MyNewProducts> newProdcuts){
            this.newProducts = newProducts;
        }
    
    }
    

    Then from your JSP page you would access it as such:

    <s:iterator value="newProducts" status="stat">
        <div> <s:property value="%{attributeName}" /> </div>
    </s:iterator>
    

    This will eliminate some unnecessary database calls by maintaining your list of products in the value stack and the conditional in the prepare method will populate the list if for some reason it is null.

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

Sidebar

Related Questions

I'm new to using Linq and just started a side project to learn some
I have just started to learn ASP.NET MVC 3 form this book and I
I just started to learn how to use action listeners. To my understanding it
I just started to learn about mod rewrite process. Now, I got some problems
Just started my first MVC 2.0 .net application. And I set up some default
I just started to learn C programming. In my book there is this piece
I just started to learn MVC and am trying to understand how it works.
I have just started to learn the very basics of Java programming. Using a
I have just started to learn ASP.NET MVC. When comparing ASP.NET MVC with Web
everyone... I've just started to learn how to create process and thread using Windows

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.