What is the source code for include() & forwrd() method
servlet program?



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

Post New Answer

More JavaScript Interview Questions

What does “1?+2+4 Evaluate to? What about 5 + 4 + “3??

0 Answers  


Where are cookies actually stored on the hard disk?

0 Answers  


disbable back option by java script

5 Answers   HG, TCS,


What are the types of variables in javascript?

0 Answers  


<script type="text/javascript"> function dispValue(e) { v = function (s) { return e.name + ': ' + s } if (e.type == "") return v(e.checked ? "" : ""); else return v(e.value); }

0 Answers  






What is the difference between null & undefined?

0 Answers  


What is postback in javascript?

0 Answers  


What is lazy instantiation in java?

0 Answers  


write a programme to solve a formula for compound interest using html tags. I want to know how a formula containing degree (raise to the power) can be solved.

1 Answers  


List some features of javascript.

0 Answers  


What are the datatypes in javascript?

0 Answers  


What are all the types of Pop up boxes available in JavaScript?

0 Answers  


Categories