Win a copy of Head First Agile this week in the Agile forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

forwarding within the application  RSS feed

 
Raj Kumar Bindal
Ranch Hand
Posts: 418
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Number of ways in which we can forward from servlet to jsp or jsp to jsp or jsp to servlet or servlet to servlet :

1.requestDispatcher.forward("/relative path")
2.response.sendRedirect("/relative path");
3.Through event handling,like button click etc.
4.PageContext.forward("/relative Path")

Please let me know if i am missing any other way.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66208
151
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
2 and 3 are not forwards.
 
Pranav Pal
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In 1 & 4, same request is forwarded
In 2 & 3, the request is new
 
Raj Kumar Bindal
Ranch Hand
Posts: 418
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So,i can conclude that these are only 4 ways through which we can forward/transfer the control into the application.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is only one way to forward.
That is to use RequestDispatcher.forward or one of the JSP mechanisms that will, in turn, use RequestDispatcher.forward.

There are other ways to transfer control to another page or resource and there are ways to include or import other pages and/or resource. I'm not sure what value there is in asking people to dream up all the ways this can be done. What are you trying to accomplish? What have you tried, and why is it not satisfactory to you? Maybe someone can suggest a better alternative.
[ November 25, 2007: Message edited by: Bear Bibeault ]
 
Raj Kumar Bindal
Ranch Hand
Posts: 418
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ben,
include and import are quite fine.
Actually this question was asked in an interview and i told the mentioned the 4 ways.
Now,i think these are the only 4 ways as i am not getting any new way.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!