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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T15:58:57+00:00 2026-06-17T15:58:57+00:00

I am trying to create a dummy project of Online Book Ordering System to

  • 0

I am trying to create a dummy project of Online Book Ordering System to practice JSP. Am trying to follow MVC in it.

By definition, in MVC any changes in model must not need any changes in View/Controller.

In Model, I created Customer class (having customer attribute and its getter-setters) and CustomerCollection class (which performs CRUD on customer data)

In Controller, I have a Controller servlet which invokes CustomerCollection, accesses Customer data and adds the list of customers as an attribute of request.

In view, I have JSP which accesses the list of custoemers added by controller and displays it in the page as follows:

<table id="customerTable">
                <tr id="customerTableHeaderRow">
                    <th>Id</th>
                    <th>First name</th>
                    <th>Last name</th>
                    <th>Address</th>
                    <th>Phone number</th>
                    <th>Gender</th>
                </tr>
                <%                  
                    for(Customer customer: customers)                        
                    {  
                %>
                <tr class="customerTableRow">
                    <td><%= customer.getId() %></td>
                    <td><%= customer.getFirstName() %></td>
                    <td><%= customer.getLastName() %></td>
                    <td><%= customer.getAddress() %></td>
                    <td><%= customer.getPhoneNumber() %></td>
                    <td><%= customer.getGender() %></td>                    
                </tr>   
                <%      
                    }
                %>
 </table>

However now I believe that when I make any changes to my database, like adding any column to a customers table, I have to modify for loop in view to display the content of that column too which is not good.

So whats wrong here? Am doing it wrong? Or is there any standard way to do the same?

  • 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-17T15:58:57+00:00Added an answer on June 17, 2026 at 3:58 pm

    In MVC approach, the JSP file should not contain any line of Java code, you should be using JSTL and the servlet class should not contain any JDBC code, you should use DAO. So basically you are implementing it right, just need to make few changes as below.

    By naming convention your CustomerCollection should be CustomerDAO.
    Replace Scriptlets with JSTL and EL.

    Customes in jsp can be accessed as below.

    <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
    <table>
    <c:forEach items="${customers}" var="customer">
        <tr>
            <td>${customer.firstName}</td> - access all your attributes this way
        </tr>
    </c:forEach>
    </table>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am a completely new to mvc and trying to create a dummy application
I'm trying to create a dummy application that maintains a list of tasks. For
I'm trying to create a dummy BaseHttpContext to do some (mock) testing without having
I'm trying to create a dummy variable for good and bad by extracting numbers
I am trying to create a dummy wrapper class ( a mongoengine Document )
I'm trying to generate some dummy records in MySQL and need to create random
I have a data frame. I'm trying to create a dummy variable that is
I'm trying create a bot which automatically likes Facebook posts. Using Mechanize I can
I am trying create a delegate representation of constructor by emitting a Dynamic Method,
Ok so I am trying create a login script, here I am using PHP5

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.