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 trim in javascript?
what are the differences between as2 and as3?
In which location cookies are stored on the hard disk?
List out all the falsifying tokens in Javascript?
What are javascript closures?when would you use them?
How does javascript work?
Write a program to check whether a given number is a palindrome or not?
Why is var better than let?
How can a particular frame be targeted, from a hyperlink, in javascript?
just for testing
what data type javascript supports?
What does break and continue statements do in javascript?