Bookmark Topic Watch Topic
  • New Topic

jsp:forward and sendredirect  RSS feed

 
aakash bhatt
Ranch Hand
Posts: 182
  • Mark post as helpful
  • send pies
  • Report post to moderator
What is Best pratctical approcah or examples when to use jsp:forward and sendredirect
 
Dhananjay Ghanwat
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Report post to moderator
Use JSP forward when you want pass any object apart between two pages without using session
you can use request.setAttribute() then forward
forward is faster than sendRedirect as it happens in the server without coming to client.
 
Mathew Kuruvilla
Ranch Hand
Posts: 145
  • Mark post as helpful
  • send pies
  • Report post to moderator
I've heard it said that the browser comes back to the original page which issued the jsp:forward or sendRedirect. Which of these methods comes back from an invocation to jsp:forward or sendRedirect from the middle of a jsp page?
Thanks.
 
R K Singh
Ranch Hand
Posts: 5390
1
Java Spring
  • Mark post as helpful
  • send pies
  • Report post to moderator
Originally posted by aakash bhatt:
What is Best pratctical approcah or examples when to use jsp:forward and sendredirect

If your page is on the same server use forward.
If your page is on different server use sendRedirect()
But sometimes we want browser to keep track, at that time also we can use sendRedirect().
Actually sendRedirect() sends "page moved" header with new URL to browser and then browser sends again request for new page.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66156
146
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Report post to moderator
I'd make the general criteria:
If you need to keep within the context of the same request, use forward.
If you want to create a new request context, use redirect.
It doesn't really have anything to do with whether you are on the same server or not, except that you cannot forward to a resource outside of the current web application context.
hth,
bear
 
Mathew Kuruvilla
Ranch Hand
Posts: 145
  • Mark post as helpful
  • send pies
  • Report post to moderator
I am surprised to know that a web application context exist on 2 different servers? How does that work/
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Report post to moderator
Mattew,
This thread is over 4 years old.
You'd be better off starting a new one if you have a new question.
Link to this one if need be.
-Ben
 
    Bookmark Topic Watch Topic
  • New Topic
Boost this thread!