program for RequestDispatcher in servlets?

Answer Posted / sudhakar

import javax.servlet.*;
import javax.servlet.http.*;

public class TestDispatcher extends HttpServlet throws
IOException, ServletException {
public void doGet(HttpServletRequest request,
HttpServletResponse response) {
RequestDispatcher dispatcher =
request.getRequestDispatcher("/template.jsp");
dispatcher.forward(request, response);
}
}

Is This Answer Correct ?    17 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the difference between context parameter and context attribute?

759


Why doesn’t a servlet include main()?

807


Can we use the constructor, instead of init(), to initialize servlet?

855


What is a cookie What is the difference between session and cookie

845


Differentiate between the web server and application server?

805


What are the functions of the servlet container?

1358


Can filter be used as request or response?

756


What is the procedure of invoking different servlet in a different application?

795


What is the difference between the getrequestdispatcher(string path) method of javax.servlet.servletrequest interface and javax.servlet.servletcontext interface?

802


What do you mean by httpservlet?

792


When Servlet is unloaded?

872


What is load-on-startup in servlet?

832


What is the requirement of servlet config and servlet context implemented and how are they implemented?

786


What do you mean by request dispatcher in servlet?

888


Which event is fired at the time of session creation and destroy?

1148