[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 760
  • Last Modified:

servlet sendRedirect

Hi,

I am reading about servlet sendRedirect as below

http://www.javatpoint.com/sendRedirect%28%29-method

orward() method      sendRedirect() method
The forward() method works at server side.      The sendRedirect() method works at client side.
It sends the same request and response objects to another servlet.      It always sends a new request.
It can work within the server only.      It can be used within and outside the server.
Example: request.getRequestDispacher("servlet2").forward(request,response);      Example: response.sendRedirect("servlet2");


I ran this example by creating fresh dynamic web project and copying src and web.xml, index.html files.
I redirected to google page as below

https://www.google.co.in/#q=sai

what is meaing of '#q '


I have not clearly understood the differences between redirect, forward.Advantages, disadvantage, practical uses of each of them.



please advise
Any links resources ideas highly appreciated. Thanks in advance
0
gudii9
Asked:
gudii9
1 Solution
 
mccarlIT Business Systems Analyst / Software DeveloperCommented:
A "forward" as the quoted text says, happens totaly within the server. It is basically just one servlet (the one calling forward() method) handing the responsibility of processing the request to a second different servlet. Note that this is totally transparent to the client, it knows nothing about this.

A "redirect" is a response that the servlet sends back to the client application (such as a web browser) that tells the client to go and look for whatever it is after at a different URL. Generally, the client/web browser will then make a separate request to this new URL to try and get what it is after. Obviously in this case, the client application is aware of what is happening, eg. if the client is a web browser, you might see the address change in the address bar.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now