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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T21:01:07+00:00 2026-05-31T21:01:07+00:00

If one Servlet is mapped twice, using two different names (as shown bellow) how

  • 0

If one Servlet is mapped twice, using two different names (as shown bellow) how many instances of the Servlet will be created by the container?

One instance or two or it is container dependent?

<servlet>
    <servlet-name>servlet1</servlet-name>
    <servlet-class>com.me.servlet.MyServlet</servlet-class>
</servlet>

<servlet-mapping>
    <servlet-name>servlet1</servlet-name>
    <url-pattern>/page1.html</url-pattern>
</servlet-mapping>


<servlet>
    <servlet-name>servlet2</servlet-name>
    <servlet-class>com.me.servlet.MyServlet</servlet-class>
</servlet>

<servlet-mapping>
    <servlet-name>servlet2</servlet-name>
    <url-pattern>/page2.html</url-pattern>
</servlet-mapping>
  • 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-31T21:01:08+00:00Added an answer on May 31, 2026 at 9:01 pm
    <servlet>
        <servlet-name>FooServlet</servlet-name>
        <servlet-class>foo.FooServlet</servlet-class>
        <init-param>
            <param-name>foo</param-name>
            <param-value>bar</param-value>
        </init-param>
    </servlet>
    

    Since each servlet has its own configuration, there must be at least one servlet instance per servlet definition.

    The Servlet 3.0 specification says:

    For a servlet not hosted in a distributed environment (the default),
    the servlet container must use only one instance per servlet
    declaration
    . However, for a servlet implementing the
    SingleThreadModel interface, the servlet container may instantiate
    multiple instances to handle a heavy request load and serialize
    requests to a particular instance.

    In the case where a servlet was deployed as part of an application
    marked in the deployment descriptor as distributable, a container may
    have only one instance per servlet declaration per Java Virtual
    Machine (JVM™). However, if the servlet in a distributable application
    implements the SingleThreadModel interface, the container may
    instantiate multiple instances of that servlet in each JVM of the
    container.

    SingleThreadModel should be avoided.

    Assuming a non-distributed environment, the posted descriptor fragment will result in two servlet instances.

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

Sidebar

Related Questions

I have web application written in java using Eclipse. It has just one servlet
I created one GWT webapplication project.Inthat i want to create servlet program,but in that
I am creating one application in which i am using jsp/servlet.. I want to
fact : servlet container creates one instance per servlet(hope i am correct on this
I have one Servlet name EditEvent and one JSP which contains two forms. One
I knew only one servlet instance (One instance for one servlet basis) will be
I just wonder why does only one copy of a servlet get created. And
I have two jsp pages and one servlet. When user clicks submit button then
In servlet 3.0 one can use startAsync to put long work in another thread,
One of my tables in my SQL database has a growth rate of two

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.