I'm faced with constructing an HttpUrlConnection of method "POST" in code and using it to navigate, sending the user there as if they had submitted a form.
current steps: 1) User clicks a link on my web app 2)my webapp whips up a SAML document based on a number of parameters 3)my webapp adds the SAML document to the body of a programmatically created URLConnection of method "POST" 4) I use java.net.HTTPURLConnection to send the post to the remote server for authentication.
right now, the remote server happliy sends back HTML that scrolls by nicely in my server console window. my user, of course, needs to navigate to that remote site. If I follow up with a redirect or forward to that remote site, it generates another request, which isn't properly formed for authentication. it is a "GET", for starters.
I think I could also stick the document in as a request parameter, but I'm still faced with the central problem of how to navigate using a URLConnection. My server is making the request instead of the client, so I need another way around this.
I have thought of just making a form with hidden fields, but I don't think there is a way to alter the form's request parameters on the fly, or is there?
so perhaps I shouldn't use HttpUrlConnection. Is there a way to make a POST request on the fly and redirect to there? The purpose is to authenticate against a webapp firewall called Reactivity. Authentication is done through and encrypted, signed SOAP envelope any ideas?
I was considering using jakarta httpClient and still might, but I think it leaves me with the same problem. How do I make a request from the server and then redirect the client to that same resource without generating another request?
Ben, that is exactly what I ended up doing. The initial server side post returned an HTML form that I pasted back into the browser with response.getWriter().write(theReturnedHTML) and it worked! Thanks