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 to have the status line update when the mouse goes over a link (the support of the status line is sporadic)?
What are two-way data binding and one-way data flow, and how are they different?
What is the difference between innerHTML and innerText?
How to create multiline strings in javascript?
How to get checkbox status whether it is checked or not?
Does javascript care about whitespace?
Is javascript frontend or backend?
Are Attributes and Property the same?
Can we create buttons in JavaScript ? if yes how? pls provide sample code... Thanks in advance.....
Describe briefly the major use of java script on client side
How to create scale in P info
Should you disable javascript?