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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T09:57:53+00:00 2026-05-27T09:57:53+00:00

I am working on a small booking site right now. And that site has

  • 0

I am working on a small booking site right now. And that site has one single servlet with a big if-else block with around 85 conditions to redirect the request to the appropriate jsp. The same servlet contains some business logic. This servlet directly calls the data access objects. Those data access objects also have some business logic. So the business logic is shared between the servlet and the DAOs. I have two confusions.

1) The servlet is an anti-pattern. So I am trying to make it smaller and divide it into multiple servlets so that each servlet have some kind of specific purpose. My question is should I make one servlet for each conditions. That would make 85 different servlets.

2) How many layers should I have between the DAO and the servlets. I am thinking two because I need to one layer would convert the input specific to the web front end to a generalized request. And the second layer would process the generalized request and call the DAO’s when required. So that if later on when we decide to make a mobile app. We just need to make one layer of processing of request specific to the mobile front and and convert it to a generalized request. But this is leading to repeated code. I am a little confused between one layer and two layers.

I know its a big question to read. But thanks for your time and replies in advance.

  • 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-27T09:57:54+00:00Added an answer on May 27, 2026 at 9:57 am
    1. If there are actions/conditions that are similar in purpose or in what they act upon, they can be combined into classes that have multiple handler methods. For example, all servlets that act on users could be combined into a single class. Whether or not that makes sense depends on information we don’t have.

    2. How many layers should you have? Don’t know. In general there is at least one, a service layer. Services aggregate DAO functionality into transactional units. The condition handlers manage the interface between web and business layers.

    It sure looks like you’re completely re-inventing a wheel which has been invented many times already. Consider either using an existing framework, or streamlining your existing code: instead of making multiple servlets to handle the conditions, dispatch to a command handler as de-coupled from the servlet spec as possible.

    If you’re aiming for drop-dead simplicity, something like Bear’s Front Man is a thin, cute layer that does away with a lot of complexity and noise. Something like Guice Servlets allows dependency injection without a full-blown Spring/etc. stack.


    Classes that handle a specific URL (or “command”–see any command pattern documentation) don’t need to be actual servlets; they can be generic classes.

    They may be servlets–but the looser the coupling to the servlet specification you have, the easier things are to test and extend.

    Getting from a URL to a “command” can be as simple as looking up a command in a map, instantiating the appropriate class, passing along various artifacts (e.g., request and session parameters), and calling a method in the implementation. In a sense, every framework ends up working like this on some level.

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

Sidebar

Related Questions

Right now I'm working on small project, submitting very simple jobs and I'm working
Iam working on small booking room system. In my solution I have a Reservation
Im working on a small application to try out an idea that I have.
I'm working on a small app that uses the Facebook API. What I want
I'm working on a small app that makes use of the jQuery plugin Fullcalendar.
I am working on small scale deployment system for our in-house software that manages
I'm working a small drupal site, and I'm trying to pull and push changes
I have been working on small site admin but have run into an odd
We have service that's working with small to large sets of data (document generation),
I am new in android and currently working on small application that works on

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.