What is the use of RequestDispatcher in servlet?
Answer Posted / kollu sreenivasa rao
When you want send your request to another servlet/jsp from
your servlet, we can use RequestDispatcher.
There are two ways to get reference of RequestDispatcher.
1)If you get requestdispatcher reference from
ServletContext, you have to specify the absolute url as
argument in getRequestDispatcher method like below.
RequestDispatcher dispatcher =
getServletContext().getRequestDispatcher("/my_other_app/servlet/SomeServlet");
dispatcher.forward(request, response);
2)If you get requestdispatcher reference from
ServletRequeset, you have to specify the relative url as
argument in getRequestDispatcher method like below.
RequestDispatcher dispatcher =
request.getRequestDispatcher("SomeServlet");
dispatcher.forward(request, response);
Is This Answer Correct ? | 18 Yes | 11 No |
Post New Answer View All Answers
What is Client-Server Computing?
What is url encoding and url decoding
Whether we can get deadlock situation in servlets?
What is session tracking?
What do you mean by session tracking?
What is the difference in between the httpservlet and generic servlet?
What's the servlet interface?
What are the type of protocols used in httpservlet?
What are sessions in servlets?
What are the common methods that are included in the http servlet class?
Describe some assignments that are executed by servlet container?
What is servlet mapping?
How can an existing session be invalidated?
Which protocol will be used by browser and servlet to communicate
What are the differences between forward() method and sendredirect() methods?