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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T21:32:10+00:00 2026-06-03T21:32:10+00:00

I start learning Spring MVC yesterday, then I figure that in Spring MVC (or

  • 0

I start learning Spring MVC yesterday, then I figure that in Spring MVC (or another framework maybe) we can have many servlet in one web apps.

Servlet have a url-pattern that will be matched if there is any http request. In other hand, we can just using @RequestMapping to do a mapping for http request.

So the question is why, when and in which case we should use multiple servlet ?

What is the best practice for that ?

Thank you.

  • 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-03T21:32:11+00:00Added an answer on June 3, 2026 at 9:32 pm

    Usually with Spring MVC, you declared a single servlet in web.xml like the following :

    <servlet>
        <servlet-name>ActivityReplicator</servlet-name>
        <servlet-class>
            org.springframework.web.servlet.DispatcherServlet
        </servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>
    
    <servlet-mapping>
        <servlet-name>ActivityReplicator</servlet-name>
        <url-pattern>/</url-pattern>
    </servlet-mapping>
    

    This servlet will be responsible to handle every request to your application and to dispatch them to the right Controller.

    Using a single servlet limits the configuration that has to be done in web.xml. Spring Controllers are specially built to handle redirections coming from the DispatcherServlet. As Nathan explained, controllers are less complicated to configure.

    I would suggest a Controller for every domain found in your application. For exemple, one controller for user management, another for forum post management. You can read on Restfull controllers using Spring to have an idea of how many controllers to implements.

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

Sidebar

Related Questions

I just start learning WPF, is that possible I can create an IE toolbar
I'm learning Spring 3 MVC for a project I'll start soon for a client
I am learning spring mvc and hibernate. i have just finished simple site with
I have just started learning Spring MVC 3 and I have problem right at
I just start learning to write web services yesterday, kinda fascinating. I created an
Where can I start learning Windows Form designing? For example: Microsoft Zune player, Buttons,
I plan to start learning a Java web framework (I love the Java API)
I got the Wrox.Beginning.JavaScript.3rd.Edition and wanted to start learning it from scratch, then my
I just installed the latest SDK from Apple so I can start learning iPhone
I'm learning java and I have made simple program that simply reads value from

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.