wood burning stoves*
The moose likes Servlets and the fly likes POSTing hidden params from a servlet 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 "POSTing hidden params from a servlet" Watch "POSTing hidden params from a servlet" New topic
Author

POSTing hidden params from a servlet

Eric Carlson
Greenhorn

Joined: Mar 19, 2006
Posts: 2
Hi, I'm trying to code an ecommerce site with all the validation done in my servlet. The example they give is just to use a static web page, which is no good for me. So I'm basically trying to duplicate in a servlet what the static one does. Theres nothing special about the static one:

<FORM METHOD="POST" ACTION="https://secure.example.com/authorize/process.cgi" onsubmit="return validator(this)">

<INPUT TYPE=hidden NAME="merchant" VALUE="$merchant">
<INPUT TYPE=hidden NAME="amount" VALUE="$amount">
<INPUT TYPE=hidden NAME="orderref" VALUE="$orderref">
..
</FORM>

My form calls my the validation servlet to populate the vars, then I'm trying to pass them all onto the merchant site exactly as if the user clicked the submit button in the above form. I can't use res.sendRedirect("https://secure.example.com/authorize/process.cgi") or all the params get lost. If I try grabbing the url, adding all the params and doing a POST manually, it does work but the browser never leaves my site, in other words the POST returns the output from the merchant site as a webpage stream, which means the users browser sees the content of the page with the url of my site, not the merchants. Hope I've explained this right, thanks. Heres that POST code, which works but isn't a redirect:



[Edit by Dave to add code tags]
[ March 19, 2006: Message edited by: David O'Meara ]
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41155
    
  45
Hello "Erik The Viking"-
Welcome to JavaRanch.

On your way in you may have missed that we have a policy on screen names here at JavaRanch. Basically, it must consist of a first name, a space, and a last name, and not be obviously fictitious. Since yours does not conform with it, please take a moment to change it, which you can do right here.

Enjoy your time here.


Ping & DNS - my free Android networking tools app
Eric Carlson
Greenhorn

Joined: Mar 19, 2006
Posts: 2
Whoops! Sorry, Ok hope the names ok now.
[ March 19, 2006: Message edited by: Eric Carlson ]
Manesh Kumar
Ranch Hand

Joined: Mar 21, 2006
Posts: 94
Originally posted by Erik The Viking:
[QB]Hi, I'm trying to code an ecommerce site with all the validation done in my servlet. The example they give is just to use a static web page, which is no good for me. So I'm basically trying to duplicate in a servlet what the static one does. Theres nothing special about the static one:

<FORM METHOD="POST" ACTION="https://secure.example.com/authorize/process.cgi" onsubmit="return validator(this)">

<INPUT TYPE=hidden NAME="merchant" VALUE="$merchant">
<INPUT TYPE=hidden NAME="amount" VALUE="$amount">
<INPUT TYPE=hidden NAME="orderref" VALUE="$orderref">
..
</FORM>

You need to use response.sendRedirect("http://merchantURL?<construct parameters here");

You need to programatically form the query string and then send redirect to
the client.

This will redirect to the merchat site.


Manesh
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: POSTing hidden params from a servlet
 
Similar Threads
Display XML/HTML file in TextArea in Web page
using ajax and struts iterate tags
JSP to servlet
Trying to post from servlet directly to server see code
Two "Post"s on the same html page valid?