program for RequestDispatcher in servlets?

Answer Posted / avinah kapoor

import javax.servlet.*;
import javax.servlet.http.*;
public class RequestDispatcherDemo extends HttpServlet
{
public void doGet(HttpServletRequest
req,HttpServletResponse res) throws ServletException
{
res.setContentType("text/html");
PrintWriter out=res.getWriter();
RequestDespatcher rd=req.getRequestDispacher("welcome");

rd.forward(req,res);//it forwart the response to
welcome servlet page but cant take resource calling page.
}
}

Is This Answer Correct ?    1 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Can filter be used as request or response?

752


What are the life cycle methods of a servlet?

804


Is servlet thread safe?

768


What is the servlet?

850


What is servlet and its advantages?

796


How to commuincate between an applet and a servlet?

802


What are the ways to handle multi-threading in servlets?

857


What is the difference between 2 types of servlets?

892


What is the procedure for initializing a servlet?

776


When is the servlet instance created in the life cycle of servlet? What is the importance of configuring a servlet?

812


Explain jsessionid?

826


Which are the different ways you can communicate between servlets?

768


How do you create a cookie using servlet?

866


Explain is servlet mapping?

788


Explain the difference between servlet and cgi?

844