File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes Redirect, but POST wanted. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Redirect, but POST wanted." Watch "Redirect, but POST wanted." New topic

Redirect, but POST wanted.

Vishal Saxena

Joined: Apr 23, 2003
Posts: 26
If I redirect to a URL, I achieve a GET. How to achieve a POST ?

Thx -V
Amol Desai
Ranch Hand

Joined: Jan 29, 2003
Posts: 82
This link below could be useful to you.
David O'Meara

Joined: Mar 06, 2001
Posts: 13459

It's a thought, but I'm not sure it will work.
One thing to try is to redirect to an intermediate page, and have the intermediate page do an 'auto-post' to the page you want.
The intermediate page would look like this:

Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
I have seen this submit done in a Javascript "page complete" event. Anybody recall that actual event name? Is it necessary to put it there, or is it ok as shown in the post above? Let us know how this works out for you!

A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63865

I have used the technique that David outlined above many times with great success.

[Asking smart questions] [About Bear] [Books by Bear]
Dana Hanna
Ranch Hand

Joined: Feb 28, 2003
Posts: 227
The only bad side to David's approach is that the back button won't let the user back through (unless they click it REAL fast).
I agree. Here's the link:
subject: Redirect, but POST wanted.
It's not a secret anymore!