what is request dispatcher and how does it work?
Answer Posted / mahesh bolla
Request dispatcher is used to transfer the same rquest to
another page/servlet without user interaction.
Exampe:
Suppose we have 2 servlets.
Write the below code in first Servlet
----
----
RequestDispatchet rd = request.getRequestDispatcher
("/secondServlet");
rd.forward(request, response);
//or rd.include(request, response);
---
----
Similar thing can be done in JSPs also
Write the below code in one.jsp
<js:forward page="two.jsp"/>
or
<jsp:include page="two.jsp");
If we use "forwad" then request will transfered to the
second page but not returned back to first page. We can see
only the second page's output.
If we use "include" then the sencond page itself will be
included in the first page. Then the output is the
combination of both the pages.
| Is This Answer Correct ? | 34 Yes | 2 No |
Post New Answer View All Answers
Explain about static nested classes in java?
Write a method that will remove given character from the string?
Why we use protected in java?
In the below example, how many string objects are created?
Write a program to check for a prime number in java?
What is meant by oops concept in java?
What are 3 data types?
What about method local inner classes or local inner classes in java?
How are variables stored?
What is the flag in java?
Which collection allows duplicate values in java?
How do you add an element to a set in java?
What is better- service oriented or batch oriented solutions?
What is namespace in java?
What are extraneous variables examples?