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

Which built-in method reverses the order of the elements of an array?

0 Answers  


What is escape() function?

0 Answers  


How to go next field without filling the text? Which function should we use?

4 Answers  


Why are callbacks used?

0 Answers  


In javascript chained select menus are available.first select menu is worked and others are disabled.when we select any one option then the next select menu will worked having option releated to selcted in first select menu.How it possible? what is the coading of this programme?

1 Answers  


What is arguments object in JavaScript?

0 Answers  


how to use java script

1 Answers   Infosys,


What is the requirement of debugging in javascript?

0 Answers  


What is the difference between sessionstate and viewstate?

0 Answers  


Explain with an example the use of event handlers in javascript.

0 Answers  


What is a closure and why are they so useful to us?

0 Answers  


What is console.log() and why it is used?

0 Answers  


Categories