0

I am trying to understand when we access the following URL in tomcat who's responsible for serving the request:

http://localhost:8080

When we hit this URL, is this page served by the following servlet configured in the tomcat's web.xml configuration file:

<servlet>
    <servlet-name>default</servlet-name>
        <servlet-class>org.apache.catalina.servlets.DefaultServlet</servlet-class> 
    <load-on-startup>1</load-on-startup>
</servlet>

<!-- The mapping for the default servlet -->
<servlet-mapping>
    <servlet-name>default</servlet-name>
    <url-pattern>/</url-pattern>
</servlet-mapping>

As can be seen, the URL pattern for which this default servlet gets invoked is "/", so is it this default servlet which caters this URL?

If the above is correct, I have this related question:

Usually we access any web application with its context root, so for the default servlet which is configured in the web.xml, what is the context root for default servlet?

CuriousMind
  • 8,301
  • 22
  • 65
  • 134
  • 1
    the application ROOT deployed in webapps will serve root context – Sangram Jadhav Jun 10 '16 at 07:21
  • that is what I am asking, what is the root context for this? – CuriousMind Jun 10 '16 at 07:24
  • 1
    The `/` URL pattern has a special meaning which is already explained here http://stackoverflow.com/q/4140448 It does thus NOT mean "root URL" orso. – BalusC Jun 10 '16 at 07:26
  • @BalusC: Yes "/" has different meaning, but for accessing any web application, we need its root context; this is what confuses me. what is the root context for the default servlet? And is `http://localhost:8080` served by this default servlet? – CuriousMind Jun 10 '16 at 07:30
  • 1
    Regardless of the URL, if there is no more specific servlet mapped there, then the default servlet will take over it. – BalusC Jun 10 '16 at 07:35

0 Answers0