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
Is javascript hard to learn?
What is the way to get the status of a CheckBox?
What is npm javascript?
Why typeof null is object?
Difference between private, public and static variable?
What is the statement to enable strict mode in javascript quiz?
How long does it take to learn javascript?
How to write hello world on the web page?
How can you read properties of an Object in JavaScript?
What is the difference between scripting and programming?
What is the use of Void(0)?
What do you mean by enumeration?
A milk carton can hold 3.78 litres of milk. Each morning, a dairy farm ships cartons of milk to a local grocery store. The cost of producing one litre of milk is $0.38, and the profit of each carton of milk is $0.27. Write a java program that prompts the user to enter the total amount of milk produced in the morning. Then display the number of milk cartons needed to hold milk, the cost of producing milk, and the profit for producing milk.
What is the use of a weakmap object in javascript?
What can be the challenges during testing a program or a system?