Tuesday, November 29, 2011

What is the difference betweem getRequestDispatcher() available as part of ServletContext and ServletRequest

You can get a RequestDispatcher object from either a request or the web context; however, the two methods have slightly different behavior. The method takes the path to the requested resource as an argument. A request can take a relative path (that is, one that does not begin with a /), but the web context requires an absolute path. If the resource is not available or if the server has not implemented a RequestDispatcher object for that type of resource, getRequestDispatcher will return null. Your servlet should be prepared to deal with this condition:servlet context need to give absolute path, where as request relative path is enough....
Category:Servlet Interview Questions

No comments:

Post a Comment