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 |
Which built-in method reverses the order of the elements of an array?
What is escape() function?
How to go next field without filling the text? Which function should we use?
Why are callbacks used?
In javascript chained select menus are available.first select menu is worked and others are disabled.when we select any one option then the next select menu will worked having option releated to selcted in first select menu.How it possible? what is the coading of this programme?
What is arguments object in JavaScript?
how to use java script
What is the requirement of debugging in javascript?
What is the difference between sessionstate and viewstate?
Explain with an example the use of event handlers in javascript.
What is a closure and why are they so useful to us?
What is console.log() and why it is used?