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 do I open javascript in browser?
What is the use of window object?
How do you check if a variable is an object
How fast can you learn coding?
What is an Event Bubbling in Javascript?
Difference between undefined and undeclared variables?
Which built-in method returns the calling string value converted to upper case?
What are the advantages of using external javascript?
Where do I write javascript code?
Name the two functions that are used to create an HTML element dynamically?
What is the difference between innerHTML and innerText?
What is the use of Void(0)?
What is jscript used for?
what is flux in javascript?
Explain typecasting in javascript?