what is request dispatcher and how does it work?
Answers were Sorted based on User's Feedback
Answer / 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 |
What is the use of arrays tostring () in java?
what are the application of compiler and interpreter for source program
List some features of the abstract class.
What is a nonetype?
How will you measure that int takes up only 32 bits in memory?
What is the difference between jsp and servlet?
When finalize method is called?
When will we prefer to use set and list in java and why?
what's diff between struts 1.1 & 1.2
What are examples of modifiers?
Why volatile is used in java?
Can we use string in the switch case?