what is request dispatcher and how does it work?

Answers were Sorted based on User's Feedback



what is request dispatcher and how does it work?..

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 request dispatcher and how does it work?..

Answer / sonal

yes its totaly right ...

Is This Answer Correct ?    9 Yes 1 No

Post New Answer

More Core Java Interview Questions

Is final static java?

0 Answers  


I don’t want my class to be inherited by any other class. What should I do?

0 Answers  


Does importing a package imports its sub-packages as well in java?

0 Answers  


What is the difference between a break statement and a continue statement?

0 Answers  


What does 3 dots mean in java?

0 Answers  






Suppose there is an Online shopping cart application having different objects like Cart, SelectionItem, Billing, COnfiguration, Authentication, Authorization, PersonalDetails etc. Out of this which one can be made a singleton pattern and why?

2 Answers   RBS,


What is the use of string and stringbuffer?

0 Answers  


What is the basic of java?

0 Answers  


What do you mean by exception handling in Java?

0 Answers   Atos Origin,


What about static nested classes in java?

0 Answers  


How to create packages in java?

0 Answers  


What is a method in coding?

0 Answers  


Categories