tags:

views:

24

answers:

1

I am reading Head First Servlets & JSP and I am very confused about servletcontext.

The book says there is one servletcontext per web app and have a picture with many servlets in web app but in entire web app should have only one servlet and have a thread for handling many request, right?

Why do they have many servlets in a web app? And, how does the container initialize them?

+2  A: 

The book says there is one servletcontext per web app and have a picture with many servlets in web app but in entire web app should have only one servlet and have a thread for handling many request, right?

A web app can and frequently does have multiple servlets.

If you use JSP, each JSP in fact actually becomes a servlet when it is compiled.

The configuration of the servlets in a web application is normally driven by entries in a configuration file called web.xml, which the container reads on application startup. This file associates url patterns with the Java classes defining servlets. When a request for a url is received by the container, it determines which servlet should handle the request based on this configuration and passes the request to it.

Don Roby