Servlet Request Object

What is difference b/w WITH ServletRequest Object:................RequestDispatcher rd = getServletContext().getRequestDispatcher( "/servlet/XYZServlet"); rd.forward(request, response);with ServletContext Object:.......... RequestDispatcher rd = getServletContext().getRequestDispatcher( "/servlet/XYZServlet"); rd.forward(request, response);what is difference b/w these two objects?which one is better or advatageous?any help would be appreciated.with regards,santh

Showing Answers 1 - 2 of 2 Answers

Spoorthi

  • Sep 16th, 2006
 

  If we use ServletRequest object then we have to give only the servlet name.

 For ServletContext object we have to give the relative path i.e, in a context we have more than servlet instances. so we have to give the path from context level.

  Was this answer useful?  Yes

ajaykjha

  • Oct 31st, 2006
 

In case of ServletRequest, we provide the path relative to http request while in the case of ServletContext we provide path relative to root of context.

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions