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 |
What is MEAN in javascript
Which is the best website to learn javascript?
Which built-in method adds one or more elements to the end of an array and returns the new length of the array?
How do I open javascript?
What are different types of popup boxes available in javascript?
What is NaN in Javascript?
why you used Java Script? Can it use for both client side and server side validation purpose?
12 Answers BeBo Technologies, HCL, Wipro,
How do you write an event emitter base class that allows you to add event listeners?
Can you put javascript in html?
Are javascript variables global?
Why is currying called currying?
What is the main difference between Client side JavaScript and and Server side Java Script?