Solved

servlet sendRedirect

Posted on 2014-03-27
1
662 Views
Last Modified: 2014-04-29
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
Comment
Question by:gudii9
1 Comment
 
LVL 35

Accepted Solution

by:
mccarl earned 500 total points
ID: 39960746
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now