• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Redirecting a form in jsp

 
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm sure there's a trivial solution to this but for some reason I can't figure it out.

I have an HTML form on my site that is submited to another site (i.e., ACTION="a url on someone else's site"). I need to capture some of the form data before sending it off to the other site. I tried creating a jsp that grabs the parameters I need and then calls response.sendRedirect() but in doing that I seem to lose all of the form parameters. Any ideas on how to do this?
 
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You could use a Servlet that your form submits to and in your servlet grab what you need, then forward the request from there.

response.sendRedirect()...

Um, yeah. That's what it is supposed to do. When you do a redirect, you are creating a new request. You have to forward a request to keep it's context.
[ July 23, 2004: Message edited by: Gregg Bolinger ]
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Low tech approach: in your servlet/JSP process your params as appropriate, then construct an HTML form element with all the parameters as hidden controls. In an onload handler, submit the form.

Hi tech approach: use HttpConnection to establish your own connection to the other server and perform a post operation.
[ July 23, 2004: Message edited by: Bear Bibeault ]
 
Michael J. Makunas
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Bear Bibeault:
Low tech approach: in your servlet/JSP process your params as appropriate, then construct an HTML form element with all the parameters as hidden controls. In an onload handler, submit the form.

Hi tech approach: use HttpConnection to establish your own connection to the other server and perform a post operation.

[ July 23, 2004: Message edited by: Bear Bibeault ]



Low tech: Thought about that.
High tech: Am I right in assuming you mean org.apache.commons.httpclient.HttpConnection? This sounds like the way to go.
 
Quick! Before anybody notices! Cover it up with this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic