Quantcast
Channel: Active questions tagged servlets - Stack Overflow
Viewing all articles
Browse latest Browse all 717

Servlet Mapping using web.xml

$
0
0

I have a confusion regarding the structure of the web.xml for the servlet mapping, I don't have any problem executing it but I am trying to figure out why we have such a pattern in the deployment descriptor.

<web-app><servlet><servlet-name>Servlet1</servlet-name><servlet-path>foo.Servlet</servlet-path></servlet><servlet-mapping><servlet-name>Servlet1</servlet-name><url-pattern>/enroll</url-pattern></servlet-mapping></web-app>

Now as far as my understanding whenever a request comes for url-pattern "/enroll", servlet container is going to match the servlet-name with the url-pattern and will try to find the corresponding servlet-path and will forward the control to foo.Servlet. so basically there would be two passes one for finding servlet-name and another for servlet-path, my question is if container is designed to work in the following way

<web-app><servlet><servlet-name>foo.Servlet</servlet-path><url-pattern>/enroll</url-pattern></servlet></web-app>

What would be the drawback if we used the following approach? Wouldn't that be more efficient and the response time would be fast?


Viewing all articles
Browse latest Browse all 717

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>