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
What does javascript do?
Are Typescript and Javascript the same?
What is lazy loading java?
What does ecma stand for?
Which built-in method calls a function for each element in the array?
Is javascript the future?
What is Associative Array? How do we use it?
What are the primitive data types in JavaScript?
how to write frame work Architecture in QTP
What are all the looping structures in javascript?
What do you mean by ide?
What is stack queue?
What is null in programming?
Is javascript open source?
Explain event bubbling and event capturing in javascript?