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
What is servlet collaboration?
How can you start a jta transaction from a servlet deployed on jboss?
What is meant by Servlet? What are the parameters of service method?
Explain load on start-up and its importance?
Can you use javascript in servlets?
What is the process for chaining servlet?
Explain servlet life cycle?
What is a servlet?
What is servlet instance?
How will two or three servlets interact or communicate with each other?
Which HTTP method is non-idempotent?
I have a requirement Here we have a ResultSet object that will contain 50 records i need to print those recors in to a webpage(i.e; view according to MVC architectures that mybe servlet or jsp) . Here i need to print the records 10 per page that is 1 to 10 in page one and 11 to 20 in page two like remaining will be appeared in other pages we need to display those page numbers whenever we click on that page number we will go to that page and display 10 records like we will display 5 pages it is like this << 1 2 3 4 5 next >>
Define context initialization parameters.
Is java servlet still used?
What are the different methods of session management in servlets?