Solved

servlet sendRedirect

Posted on 2014-03-27
1
723 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 36

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

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
In this post we will learn different types of Android Layout and some basics of an Android App.
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

688 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