• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

forward() and include() methods

 
deepashree deval
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic