What is the use of RequestDispatcher in servlet?
Answer Posted / kollu sreenivasa rao
When you want send your request to another servlet/jsp from
your servlet, we can use RequestDispatcher.
There are two ways to get reference of RequestDispatcher.
1)If you get requestdispatcher reference from
ServletContext, you have to specify the absolute url as
argument in getRequestDispatcher method like below.
RequestDispatcher dispatcher =
getServletContext().getRequestDispatcher("/my_other_app/servlet/SomeServlet");
dispatcher.forward(request, response);
2)If you get requestdispatcher reference from
ServletRequeset, you have to specify the relative url as
argument in getRequestDispatcher method like below.
RequestDispatcher dispatcher =
request.getRequestDispatcher("SomeServlet");
dispatcher.forward(request, response);
| Is This Answer Correct ? | 18 Yes | 11 No |
Post New Answer View All Answers
Why do you use session tracking in httpservlet?
Define declaration.
Explain the architechure of a servlet?
What is ServletConfig object?
Is it possible to have a constructor inside the servlet?
What is a deployment descriptor?
What is url encoding and url decoding
Why servlet is mostly used?
How does java thread pool work?
How can you use a servlet to generate a plain text instead of html?
Can you create a deadlock condition on a servlet?
What mechanisms are used by a Servlet Container to maintain session information?
hi actully i hav form columns with origin and destination names .as like as i need to create one more column with name amount. my requirement is when i select origin and destination columns automatically i need to get amount from database.how can i. please tel me with relative code
What exactly is a servlet?
What is api in servlet?