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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T22:16:05+00:00 2026-05-26T22:16:05+00:00

Basically a yes or no question but I am also looking for advice on

  • 0

Basically a yes or no question but I am also looking for advice on best practices for implementation.

Let me know when/if I start to go wrong.

  • I have a specific Servlet (AjaxServlet?) that will handle all AJAX requests
  • AjaxServlet maps to /ajax/* so all request URLs like /ajax/getDataFromServer will be handled by it
  • My doGet overide function is a long if/elseif chain checking the request.getPathInfo() each time
  • Each if block in doGet handles a specific url call (/ajax/getDataFromServer)

I want to return JSON and so far I have been building these strings myself. Is there a lightweight JSON package I could use. I know I could for example extend ArrayList (ArrayListJson?) and add a toJson() method and then cast any ArrayList to ArrayListJson but I’m sure this has been done already.

  • 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-26T22:16:05+00:00Added an answer on May 26, 2026 at 10:16 pm

    Your basic idea sounds OK, but it would be best to have multiple classes that each handle their own task. A method I have used successfully is to use a single servlet to intercept the call, then pass the task to some other class that actually does the implementation. For example, you could create an interface (named, say, AJAXHandler) that has a method public String performTask(HttpServletRequest request) and use the Factory Pattern in your servlet to instantiate the appropriate class (that implements AJAXHandler) and let that class do its work. The results from the performTask method (the JSON string) is then sent out. When you need a new AJAX call implemented, you just add the new class that implements AJAXHandler and update the Factory with with the new class info.

    For JSON handling, I suggest you take a look at json-simple, at http://code.google.com/p/json-simple/

    The Factory pattern is described at http://www.oodesign.com/factory-pattern.html

    Good Luck!!!

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

Sidebar

Related Questions

I know a lot of question regarding VB6 migration have been asked, but I
I know this is a trivial question. But I have search all over google
Yes, this sounds like a simple question, and it probably is. But when i
I have found article that skims over this. But my main question is do
yes, this is a homework-type question but could you please help me out? In
Yes, this is probably yet another greatest-n-per-group question... But I've tried at least a
I have found several questions and answers pertaining to my question, but I'm getting
Before I start with the real question, let me just say that I might
You have probably already guessed what my question is, but anyway, here goes: It
I know this is a weird question in words, so basically I am saying

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.