program for RequestDispatcher in servlets?

Answer Posted / sonam

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.http.RequestDispatcher;
public class dispatcher extends HttpServlet throws
IOException, ServletException {
public void doGet(HttpServletRequest request,
HttpServletResponse response) {
RequestDispatcher dis=
request.getRequestDispatcher("welcome.jsp");
dis.forward(request, response);//it will go to ur
desired page.
dis.include("Hello java");//it will display ur
message also to ur desired page.
}


}

Is This Answer Correct ?    10 Yes 5 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Why the concept of single thread model interface is used?

759


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

845


What are different ways for servlet authentication?

806


What is a web container and what is its responsibility?

767


What are the benefits of using servlet over cgi?

809


List out the difference between ServletConfig and ServletContext?

813


What are sessions in servlets?

825


Explain servlet.

818


Should I override the service() method?

889


Why is it that we can't give relative URL's when using ServletContext.getRequestDispatcher() when we can use the same while calling ServletRequest.getRequestDispatcher()?

876


What is the use of welcome-file-list?

800


Why do we have servlet wrapper classes?

821


Whether we can get deadlock situation in servlets?

836


When servlet is loaded?

826


Explain the servlet context.

837