• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

POSTing hidden params from a servlet

 
Eric Carlson
Greenhorn
Posts: 2
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Pie
Posts: 42966
73
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Eric Carlson
Greenhorn
Posts: 2
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Whoops! Sorry, Ok hope the names ok now.
[ March 19, 2006: Message edited by: Eric Carlson ]
 
Manesh Kumar
Ranch Hand
Posts: 94
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic