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 amongst jvm spec, jvm implementation, jvm runtime ?
Does treeset use compareto?
Can we use a default constructor of a class even if an explicit constructor is defined?
Can you explain the private protected field modifier?
What are the different tags provided in jstl?
What does this () mean in constructor chaining concept?
What is widening and narrowing in java? Discuss with an example.
What is flush () in java?
What is generic class?
What is final, finally, finalize?
What is re-factoring in software?
How will you calculate the depth of a binary tree if the tree contains 15 nodes?
You can create a string object as string str = “abc”; why cant a button object be created as button bt = “abc”;? Explain
How are multiple inheritances done in Java?
What purpose do the keywords final, finally, and finalize fulfill?