What is the source code for include() & forwrd() method
servlet program?



What is the source code for include() & forwrd() method servlet program?..

Answer / sunny

1. forward should be called before the response has been
committed to the client.

public class Dispatcher extends HttpServlet {
public void doGet(HttpServletRequest req,
HttpServletResponse res) {
RequestDispatcher dispatcher =
request.getRequestDispatcher
("/template.jsp");
if (dispatcher != null) dispatcher.forward
(request, response);
}
}

2. Includes the content of a resource (servlet, JSP page,
HTML file) in the response.

public class Dispatcher extends HttpServlet {
public void doGet(HttpServletRequest req,
HttpServletResponse res) {
RequestDispatcher dispatcher =
getServletContext
().getRequestDispatcher("/banner");
if (dispatcher != null) dispatcher.include
(request, response);
}
}

Is This Answer Correct ?    0 Yes 1 No

Post New Answer

More JavaScript Interview Questions

Name some of the built-in methods and the values returned by them.

0 Answers  


What is meant by object oriented programming?

0 Answers  


Write a Program using Servlet and JDBC for developing online application for displaying the details of Cars owned by the residents in XYZ society. Make necessary assumptions and create appropriate databases

0 Answers   Ignou,


What is javascript namespacing?

0 Answers  


What is namespacing in javascript and how is it used?

0 Answers  






Can you have a function within a function in javascript?

0 Answers  


How to create an input box?

0 Answers  


Is javascript necessary?

0 Answers  


what will happen and why if i will acess the methods of superclass which is declared as private by a object of same subclass.

0 Answers  


Is javascript case sensitive language?

0 Answers  


What does unshift() function do in Javascript?

0 Answers  


How to show progress bar while loading using ajax call?

0 Answers  


Categories