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 do you extend classes Code snippet: const circle = { radius: 20, diameter() { return this.radius * 2; }, perimeter: () => 2 * Math.PI * this.radius };
What are two-way data binding and one-way data flow, and how are they different?
How can javascript make a web site easier to use? That is, are there certain javascript techniques that make it easier for people to use a web site?
List some features of javascript.
How to reload a page using JavaScript?
What is the Use of true or false in Ajax cal using Java Script?
What is servlet in javascript?
What is NaN?
Why is javascript so hard?
How do you implement Ajax using hide() function in JQuery?
What is the use of window object?
How to get value from dropdown (select) control?