File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes forward() and include() methods Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "forward() and include() methods" Watch "forward() and include() methods" New topic

forward() and include() methods

deepashree deval

Joined: Oct 20, 2008
Posts: 12
Can anybody give me a real time scenario where can i use forward() method and in which situation i should go for the include()method for redirection
vipin joseph

Joined: Feb 17, 2008
Posts: 4
Include method is used when we want to include some external files in our Servlet (eg: html, javascripts). If you want to show some advertisements in your sevlet code you can include the avertisement page as an image or html file.

We use forward method to navigate the request and response object to another resouce on the same server.
suppose we want to assign a jsp to display the contents we can navigate from the servlet to jsp using forward method. here servlet is reponsible for data processing and jsp is for display (MVC pattern follows this)
I agree. Here's the link:
subject: forward() and include() methods
It's not a secret anymore!