• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Work of sendRedirect() method

 
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Rancher
Posts: 43081
77
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I got idea

Thanks a lot
reply
    Bookmark Topic Watch Topic
  • New Topic