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 |
Difference between '=', '==' and '===' operators?
Write the code to maximize an image using javaScript?
Can we learn javascript without knowing java?
Explain few difference between null, undefined or undeclared javascript variable?
What are the primitive data types in JavaScript?
What are undefined and undeclared variables?
What is a module code?
What are trailing whitespace?
What is the difference between childNode and children?
What can I build with javascript?
What is null in programming?
Where do I write javascript code?