How can we locate a servlet object in the code by it's object name?
A. In web.xml you map servlet and define url pattern. Now this url-pattern is used for calling servlet.
<servlet> <servlet-name>MyServlet</servlet-name> <servlet-class>roseindia.MyServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name> MyServlet </servlet-name> <url-pattern>/ MyServlet </url-pattern> </servlet-mapping>
A Servlet can get a list of all other Servlets in the Servlet Context by calling getServletNames on the ServletContext object. ServletContext is available through the ServletConfig object's getServletContext method. After obtaining the reference to another Servlet that Servlet's methods can be called.
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.