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

Whats the advantages using servlets over using CGI?

592


How to find whether a parameter exists in the request object?

673


Why do we need a constructor in a servlet if we use the init method?

522


What are the difference between session and cookies in servlet? Explain

570


why we should override only no-agrs init() method.

684






What are the types of protocols supported by httpservlet ?

714


What is the use of send redirect () method?

594


What are the uses of servlet

639


Explain their methods? Tell me their parameter names also have you used threads in servlet?

591


What is a servlet engine?

553


Explain is servlet mapping?

592


How many objects of a servlet is created?

800


What is the difference between the servlets and cgi programs?

559


What are the jobs performed by servlets?

593


What is lazy loading and what is Generic Servlet Class?

615