What is the source code for include() & forwrd() method
servlet program?
Answer Posted / 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 View All Answers
How long does it take to learn coding?
Which built-in method reverses the order of the elements of an array?
What are classes in javascript?
What is encodeuri() function?
What is camelcase in programming?
What is the most popular javascript library?
Can I learn javascript without html?
What is Javascript namespacing? How and where is it used?
Is a javascript script faster than an asp script?
What are the variables in javascript?
What is a name function in javascript?
Write a program in Java to display the IP address of the local and remote machine.
What does === mean in js?
How do I view javascript files in chrome?
What is an undefined value in JavaScript?