Originally posted by Rajeev Asthana: If this is possible, how Web Container knows where to locate the servlet when invoked from a HTML/JSP?
First of all, it is best to say "How does a web browser invoke a servlet?" Because it is not really the HTML (or HTML generated from a JSP) that does the invoking.
Second, "invoke a servlet" really means "send an HTTP request that invokes a servlet." So, what goes into the HTTP request that tells the web container which servlet to invoke? That would be the URL. So, if a web page (the HTML) has the following hyperlink:
Then when the user clicks on that link the web browser sends an HTTP GET request for the foo.baz resource. The web container will use the servlet mappings defined in the deployment descriptor (as shown in S. Subramonyan's reply) to identify the 'OhMy' servlet. This servlet is an instance of the MyServlet class, which was defined in the <servlet> definition in the DD.
Does that help?
Would anybody like some fudge? I made it an hour ago. And it goes well with a tiny ad ...