This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Servlets and the fly likes Forward or sendredirect Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Forward or sendredirect " Watch "Forward or sendredirect " New topic
Author

Forward or sendredirect

Durga Krishna
Greenhorn

Joined: Apr 05, 2007
Posts: 28
Hi friends,

I have a shopping cart application. where the user can select the items form the list, which he wants to buy.After selecting, he can click on "Buy" button. Then the user should see the payment gateway page where he can pay the amount using his credit card. Once the payment is done, the message has to be shown in my shopping cart application -"Payment done successfully".

Please tell me whether I have to use forward or send redirect here. And why?


Nicola Garofalo
Ranch Hand

Joined: Apr 10, 2010
Posts: 308
I read a very intresting article about your question.
I am sure you will find all the answers you need there

Scriptless JSP Pages: The Front Man by Bear Bibeault


Bye,
Nicola
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

I don't really see how that's related.

Forward or redirect to where? The gateway, or the "success" page? Do you control the gateway?
Nicola Garofalo
Ranch Hand

Joined: Apr 10, 2010
Posts: 308
How that article is related to redirect and forward and why?
Probably my english is very bad but i am sure i found there a really similar issue, and a solution to it, read it if you like.
If i got it wrong, well...sorry, but read that article anyway.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

I have, several years ago. Good article. Just not related.
Nicola Garofalo
Ranch Hand

Joined: Apr 10, 2010
Posts: 308
And in my opinion it keeps being related with the issue of the post.
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

below link might be help you
http://www.coderanch.com/t/434630/Struts/Post-Request-technique
Alpesh Padra
Ranch Hand

Joined: Jan 10, 2010
Posts: 41
Can anyone provide technical detail about why do we use forward and whay do we use redirect ?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60806
    
  65

Perhaps this article might help.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Prabhat Shankar
Greenhorn

Joined: Oct 08, 2009
Posts: 27
Bear Bibeault wrote:Perhaps this article might help.


Hi,

Basically main difference between forward and sendredirect is that when we want to call any JSP or Servlet which is not in my web application then we should go for sendredirect. sendredirect initiate a new request for different JSP or Servlet.


forward is used when we want to call any JSP or Servlet which is present in my web application here same request is sent to different JSP & Servlet.

Prabhat Shankar Consumer Court,Consumer Court India,Consumer Complaints,Complaint India, Web Value
Durga Krishna
Greenhorn

Joined: Apr 05, 2007
Posts: 28
I din't get proper answer from the given articles. Thanks every body.

The payment gateway is another application, not available in my server.

If I use send redirect, it will be new request object.
Then what about the values (selected items id in the page) in the request object in the current request?

And how can I show success message in the current page?

Alpesh Padra
Ranch Hand

Joined: Jan 10, 2010
Posts: 41
Indeed, it really helps me.

Thanks.
Nicola Garofalo
Ranch Hand

Joined: Apr 10, 2010
Posts: 308
Hi Durga,
the values in the request object are lost with sendRedirect, because you create a new request.

You could use session attributes instead.
Prabhat Shankar
Greenhorn

Joined: Oct 08, 2009
Posts: 27
Durga Krishna wrote:I din't get proper answer from the given articles. Thanks every body.

The payment gateway is another application, not available in my server.

If I use send redirect, it will be new request object.
Then what about the values (selected items id in the page) in the request object in the current request?

And how can I show success message in the current page?



I think payment gate way third party would have provided you to pass some credential in url parameters.

Ex:
www.java.com?user=prabhat&accNo=452556555
Durga Krishna
Greenhorn

Joined: Apr 05, 2007
Posts: 28
Any other answer please...
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

What else are you looking for?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Forward or sendredirect
 
Similar Threads
Do you model Physical Things or Processes?
Session state management
Itinerary cart
Payment Gateway - dual verification check
want to develop dynamic shopping cart