• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

POSTing hidden params from a servlet

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Whoops! Sorry, Ok hope the names ok now.
[ March 19, 2006: Message edited by: Eric Carlson ]
 
Ranch Hand
Posts: 94
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
You would be much easier to understand if you took that bucket off of your head. And that goes for the tiny ad too!
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic