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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T19:32:42+00:00 2026-05-10T19:32:42+00:00

We need some input on what is a good design pattern on using AJAX

  • 0

We need some input on what is a good design pattern on using AJAX in a Java application.

Consider a simple scenario:

  1. User clicks a button which sends a request to a Java method to fetch data from DB.
  2. Java object is returned by method and needs to be converted into a HTML table.
  3. HTML table is shown on JSP.

What we currently do:

  1. On a JSP page, user clicks ‘Show Users’ button
  2. Button using Prototype.js calls a ‘middleman’ JSP which forwards the request to the Java method to get the data from the DB.
  3. The method returns the Java object to the ‘middleman’ JSP which converts the Java object into HTML (since the AJAX call from the calling JSP won’t be able to handle the Java object directly).
  4. The HTML is then returned to the Prototype call which updates the div on the calling JSP.

Our concerns are:

  1. We would like to keep the separation of business/presentation logic and would prefer no HTML/JavaScript code inside our Java methods.
  2. Keeping (1) in mind, is having a ‘middleman’ JSP an OK way to do this? Or should we return the Java object as XML/XSLT to the AJAX request?
  3. The above way we’re doing has very little JavaScript and works in all browsers.
  4. We looked at some other packages – DWR, GWT, but either there was too much dependency on JavaScript or required UI components to be present in the Java classes.

Is our way of doing things above OK? Or is there another preferable way?

Any help/thoughts would be appreciated.

Thanks,

SP

  • 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. 2026-05-10T19:32:43+00:00Added an answer on May 10, 2026 at 7:32 pm

    Sounds fine. You are separating view components from model components. It shouldn’t matter how the call comes to the server, AJAX or not, it should be received by a controller (a servlet say) that interacts with the model, thats your Java classes that get the data from the database and forward to a JSP page for rendering the view.

    There are frameworks that could simplify the boilerplate code but the design you describe sounds fine.

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

Sidebar

Ask A Question

Stats

  • Questions 110k
  • Answers 110k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer AFAIK the official documentation is the wiki you mention. It's… May 11, 2026 at 9:33 pm
  • Editorial Team
    Editorial Team added an answer I just found out myself how to do it. I… May 11, 2026 at 9:33 pm
  • Editorial Team
    Editorial Team added an answer Are you sure it's not receiving a memory warning? It… May 11, 2026 at 9:33 pm

Related Questions

We are developing a web application that will be sold to many clients. There
I have a challenge I need some input on. I am currently recruiting programmers
Recently I've been thinking about securing some of my code. I'm curious how one
We are in the process of migrating our bug tracking to Bugzilla from a

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.