GeekInterview.com
   Home |  Tech FAQ  |   Interview Questions |  Placement Papers |  Tech Articles |  Learn |  Freelance Projects |  Online Testing |  Geeks Talk |  Job Postings |  Knowledge Base | Site Search |  Add/Ask Question

GeekInterview.com  >  Interview Questions  >  J2EE  >  Servlets
Go To First  |  Previous Question  |  Next Question 
 Servlets  |  Question 166 of 168    Print  
forward & include methods
what are forward & include methods? Why these are used?


  
Total Answers and Comments: 1 Last Update: June 30, 2008     Asked by: RajeshKumar.Guru 
  
 Sponsored Links

 
 Best Rated Answer
Submitted by: javaguru1979
 
Both forward() and include() are concrete methods of the RequestDispatcher class in the Servlet context.

forward() - this method is used to show a different resource in place of the servlet originally requested. This resource may be a jsp, a servlet etc. When a request is sent from the client to the web server through an url , the web container intercepts the request and sends it to another resource without the knowledge of the client browser. And a response is received from that resource after processing of the request is done.

include() - this method is used to tag in the contents of a  resource as a part of the response flow as if it were part of the calling servlet. If you include a jsp or a servlet, it must not attempt to change the response status code or the http headers, as any such request will be ignored.

Above answer was rated as good by the following members:
anukalaivani
June 30, 2008 10:41:20   #1  
javaguru1979 Member Since: June 2008   Contribution: 1    

RE: forward & include methods
Both forward() and include() are concrete methods of the RequestDispatcher class in the Servlet context.

forward() - this method is used to show a different resource in place of the servlet originally requested. This resource may be a jsp, a servlet etc. When a request is sent from the client to the web server through an url , the web container intercepts the request and sends it to another resource without the knowledge of the client browser. And a response is received from that resource after processing of the request is done.

include() - this method is used to tag in the contents of a  resource as a part of the response flow as if it were part of the calling servlet. If you include a jsp or a servlet, it must not attempt to change the response status code or the http headers, as any such request will be ignored.

 
Is this answer useful? Yes | NoAnswer is useful 1   Answer is not useful 0Overall Rating: +1    

 Related Questions

A GET request is a request to get a resource from the server. Choosing GET as the "method" will append all of the data to the URL and it will show up in the URL bar of your browser. The amount 
Latest Answer : get all info go in query string,post with req body.get is not secure post is secureget send limited ddata post send lot of data arnd 2 mb ...

Yes, you can invoke the JSP error page and pass the exception object to it from within a servlet. The trick is to create a request dispatcher for the JSP error page, and pass the exception object as a 
Latest Answer : 1. How do u difine an error page?2.What r the methods called in servlet life cycle?3.How can u make session variables un available?4. How to change the port no of agiven application server?5.How do udeploye an EJB in the existing application using webspehere?6.Why ...

The central abstraction in the Servlet API is the Servlet interface. All servlets implement this interface, either directly or, more commonly, by extending a class that implements it such as HttpServlet.Servlets-->Generic 
Latest Answer : servlet interface is the interface through which we can define servlets for all the servlets......bur since we generally use servlets for http protocol.....so the hierarchy is....    Servlet

Information such as the names of the parameters passed in by the client, the protocol (scheme) being used by the client, and the names of the remote host that made the request and the server that received 
Latest Answer : really, a must-know questions for a j2ee programmer ...

What information that the ServletResponse interface gives the servlet methods for replying to the client?
It Allows the servlet to set the content length and MIME type of the reply. Provides an output stream, ServletOutputStream and a Writer through which the servlet can send the reply data. 

A servlet can handle multiple requests concurrently, and can synchronize requests. This allows servlets to support systems such as on-line conferencing. Servlets can forward requests to other servers and 
Latest Answer : Practical Applications for Java Servlets    This article is compiled by the IWD Team      Source: Developing Java Servlets, James Goodwill, samspublishing.com    Servlets What are Java Servlets?  Servlets ...

What is difference between sendRedirect() and forward()..? Which one is faster then other and which works on server?

ANS: Two ways:1. Forward or redirect from one Servlet to another.2. Load the Servlet from ServletContext and access methods. 
Latest Answer : Through RequestDispatcher by obtaining object of type RequestDispatcher by getRequestDispatcher() method of ServletContext but before getting object ofReqestDispatcher we have to first obtain object of type ServletContext by getServletContext() method ...

After converting jsp into servlet which methods are present i.e all 6 methods(jspinit(),_jspService(),jspDestroy(),init(),service(),destroy()) or only 3 methods i.e either jsp life cycle methods or servlet lifecycle methods

How the server will know (i.e) when it can invoke init, service,destroy methods of servlet life cycle?
Read Answers (3) | Asked by : chandu


 Sponsored Links

 
Related Articles

The Interview Snafu

How to turn someone else’s mistake to your advantage Your dream job is about to become reality. A recruiter gave you the heads up about the perfect position at Humungous Conglomerate, Inc. You went through five interviews as well as a battery of psychological tests mandated by their HR de
 

Winning a Job Interview with a Winning Resume

Does your resume unlock your potential, take your skills to the highest level and win you the interview and the job you want now? The job market today is highly competitive and even if you think you have what it takes to get an interview you won’t get over the line without a polished, prof
 

JavaScript Window Object Timeout Methods

JavaScript Window Object Timeout Methods In this JavaScript tutorial you will learn about setTimeout clearTimeout and open methods of window object along with syntax usage and examples for each method mosgoogle center setTimeout The setInterval method of Window object is used to call a function or
 

JavaScript Document Object Methods Part II

JavaScript Document Object Methods Part II In this JavaScript tutorial you will learn about document object methods getElementsByTagName getSelection handleEvent releaseEvents routeEvent write writeln along with syntax examples and brief explanation mosgoogle center getElementsByTagName The the getE
 

JavaScript Document Object Methods Part I

JavaScript Document Object Methods Part I In this JavaScript tutorial you will learn about methods of document object along with syntax and examples This section covers captureEvents open close getElementById getElementsByName methods with explanations for each method mosgoogle center Methods of d
 

JavaScript History Object Properties and Methods

JavaScript History Object  Properties and Methods In this JavaScript tutorial you will learn about history object properties and methods length current next previous properties back forward and go methods along with syntax and examples mosgoogle center The history property has the return v
 

JavaScript Array Object Methods – Part II

JavaScript Array Object Methods Part II In this JavaScript tutorial you will learn about on array object methods slice splice toString shift and unshift methods along with general syntax and examples mosgoogle center slice By using the methods of the array object the programmer is able to retriev
 

JavaScript Array Object Methods – Part I

JavaScript Array Object Methods Part I In this JavaScript tutorial you will learn about Array Object Methods concat join pop push and reverse methods  along with general syntax and examples mosgoogle center concat The concat method is used to join two or more Array objects together to pro
 

Neuro-linguistic Programming Methods

Neuro linguistic Programming Methods There are several methods used for performing Neuro linguistic Programming on an individual for obtaining insights into the psyche of the person in order to correct to modify certain patterns of behavior These techniques are also used for Neuro linguistic trainin
 

JavaScript Event Object Properties and Methods

JavaScript Event Object Properties and Methods In this JavaScript tutorial you will learn about event object properties and methods like keycode layer offset modifiers page reason returnValue screen srcElement target srcFilter and type mosgoogle center keycode The keycode property of event object is
 





About Us  |   Privacy Policy  |   Terms and Conditions  |   Contact  |   Site Map  |   Add Question  |   Propose Category  |   RSS Feeds  |   Articles Sitemap  |   Site Updates  |   Add Resource

Copyright © 2005 - 2008 GeekInterview.com. All Rights Reserved
Page copy protected against web site content infringement by Copyscape