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 to get value of an element by class in javascript ?
What is the syntax of ‘self invoking function’? Give an example?
what is inheritence
What is new function in javascript?
When do we use JSON.stringify()?
How can I request data from the server without reloading the page in the browser?
What is are the types of the pop up box es available in javascript?
What are types of javascript?
What is difference between javascript and jscript?
How do you check if an object is an array or not?
If 2 methods have same name and same number of parameters, which one will be executed first?
How do you write an if statement in javascript?