• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Work of sendRedirect() method

 
Abhay Choubey
Ranch Hand
Posts: 34
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I have studied about sendRedirect() method and i got some point like -

If client send a request, it goes to server or container. Container calls the servlet but this servlet is unable to handle the request. so, it send the request to different servlet using sendRedirect method. This response goes to browser with status code so, browser see the status code and create a new request with new URL and send to the container for the request. So, all this thing happen internally. Client does not know what is going internally. Client see the proper output only.

i understood this thing only. so it is right and wrong.

Thanks in advance
Abahy
 
Prashant Chindhade
Ranch Hand
Posts: 77
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what you understand is right ..its perfect....

When forward is used we can pass data to the forwarded jsp/servlet using request.setAttribute() as the same request and response objects available the forwarded servlet/jsp. But using sendRedirect() we have to set the data in session or by appending the data to the URL that will be passed as argument to this method, because by calling this method a new request is created.

The forward() request is transparent to the user. It is done at server side and it is not visible to user.

The sendRedirect is not transparent to the user, if request is sendRedirect then its visible in your browser (redirect at client side).

The forward() method is faster than using sendRedirect as no network round trip to the server and back is required.
 
Ulf Dittmer
Rancher
Pie
Posts: 42966
73
  • 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Note that forward only works within a web app, generally not across web apps, and certainly not across servers. In those cases you can only use redirect.
 
Abhay Choubey
Ranch Hand
Posts: 34
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I got idea

Thanks a lot
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic