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
What is the difference between class & object?
Which is better stringbuilder or stringbuffer?
What is the main function in java?
What is get () in java?
Give me example of derived data types.
what is the use of pojo (plain old java objects)? how it is interact with crystal reports? pls urgent
Write a program to print fibonacci series
What is java literals?
When is an object subject to garbage collection?
How to sort an array from smallest to largest java?
What are the differences between this and super keyword?
What is scope of a variable?
What is hash in java?
Where is the singleton class used?
Differences between C and Java?