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 |
Explain “use strict” ?
Does apple use javascript?
Can you call a Java Applet using a JavaScript function?
How do I open a .js file?
How do I open javascript console?
How can I prevent others from reading/stealing my scripts or images?
What is MEAN in javascript
how can i change colour of a image in aspx file?
What does => mean in node js?
What are the difference between javascript and jquery?
To put a "close window" link on a page ?
what is the difference between the below two statements:- (1) var myname = "akiii"; (2) myname = "akiii";