| 1600 PMP mock questions | 1400 CAPM mock questions | 800 SCJP 6 mock questions | 600 OCAJP 7 mock questions | 590 OCPJP 7 mock questions | 556 SCWCD 5 mock questions | 500 OCEJWCD 6 mock questions | pdfDownload (java,struts, hibernet etc) | JobsJobs and Walkins |
|
Java online test
JSP online test ORACLE online test Hibernate online test Servlet online test Struts online test EJB online test C online test C++ online test Aptitude online test |
Q. What is the difference between the getRequestDispatcher(String) and getNamedDispatcher(String) methods in the ServletContext Class? |
|
|
NamedDispatcher
Returns a RequestDispatcher object that acts as a wrapper for the named servlet. getNamedDispatcher(String) method takes the name of the Servlet as parameter which is declared via Deployment descriptor. Example: Deployment Descriptor <servlet> <servlet-name>ServletTest</servlet-name> <servlet-class>com.example.ServletTest</servlet-class> </servlet> RequestDispatcher dispatch = request.getNamedDispatcher(?ServletTest??); dispatch.forward(request, response); Note: A servlet instance can determine its name using servletConfig.getServletName(); This method returns the name of the class that implements the Servlet interface or extends the HttpServlet class. RequestDispatcher Returns a RequestDispatcher object that acts as a wrapper for the resource located at the given path. RequestDispatcher dispatch = request.getRequestDispatcher("/satya"); Here "/satya" represents the url-pattern element value of the servlet class. <servlet-mapping> <servlet-name>Test</servlet-name> <url-pattern>/satya</url-pattern> </servlet-mapping> |
Suggested JobsMore Jobs >> |
|
Online Practice TestJava online testJSP online test ORACLE online test Hibernate online test Servlet online test Struts online test EJB online test C online test C++ online test Aptitude online test |