• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

include, forward and redirect

 
Sachin Ramesh Vir
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

What is the differences between the 'include' ,'forward' and 'redirect'?
[ September 26, 2005: Message edited by: Sachin Ramesh Vir ]
 
kuni patel
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i think::::

include: this is used for include any file to yr application
like in servlet:
RequestDispatcher rd=srq.getRequestDispatcher();
rd.include("/*put here yr path from where u want to get file for attachment*/");

forward:this isuseful for forwarding request to another page.

like: rd.forward("/*wright yr path where u want to go with request*/");

redirect:
this is useful for forwarding to another page without attaching request.
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sachin, this is a very common question, a useful link is here.

kuni, thanks for answering questions, we appreciate it! But please try to UseRealWords.

thanks
Dave
 
Sachin Ramesh Vir
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

3) RequestDispatcher .forward
No response is send to the browser, the web container internally redirects the request to the other page. Remember , you can redirect only to a page within current servlet context.
Also there are two flavours of RequestDispatcher , one : you get from ServletContext .The pathname must begin with a "/" and is interpreted as relative to the current context root.
Second : you get from ServletRequest. The pathname specified may be relative, although it cannot extend outside the current servlet context. If the path begins with a "/" it is interpreted as relative to the current context root


The above quote has been taken from one of the thread in this forum for that question: "Diff btw response.sendRedirect, jsp:forward and RequestDispatch .forward methods? "

I can't the understand the following lines:


Remember , you can redirect only to a page within current servlet context.





The pathname must begin with a "/" and is interpreted as relative to the current context root.The pathname specified may be relative, although it cannot extend outside the current servlet context.





The pathname specified may be relative, although it cannot extend outside the current servlet context.

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic