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 |
How can you declare a class in javascript?
How to add multiple functions in javascript?
why array is called the collection of similar datatypes?
What is singleton class in javascript? Explain
What is event target in javascript?
Explain how to detect the operating system on the client machine?
Why javascript is fast?
How compare function works javascript?
What is innertext javascript?
What is difference between undefined variable and undeclared variable?
How can we send mail using Javascript?
How do you check if a variable is an object