In my current application(A), I redirect user to a different website(B) where user logs in with his/her account and finishes some activity and now that website(B) has a button to return my application(A), the redirection happens by posting a SAMLResponse
.
When user clicks that button, user return to my application(A) with specific unique user id assigned by that website(B) in "Form Data
" of header information.Basically website B is also posting SAMLResponse
as a form parameter in a request.
How do I read this request information in php and java?
To post HTML form data to the server in URL-encoded format, you need to make an HTTP POST request to the server and provide the HTML form data in the body of the POST message. You also need to specify the data type using the Content-Type: application/x-www-form-urlencoded request header.
The get() method of the FormData interface returns the first value associated with a given key from within a FormData object. If you expect multiple values and want all of them, use the getAll() method instead.
To get started with forms, we will first install the body-parser(for parsing JSON and url-encoded data) and multer(for parsing multipart/form data) middleware. var express = require('express'); var bodyParser = require('body-parser'); var multer = require('multer'); var upload = multer(); var app = express(); app.
FormData objects are used to capture HTML form and submit it using fetch or another network method. We can either create new FormData(form) from an HTML form, or create an object without a form at all, and then append fields with methods: formData. append(name, value)
The "form data" part is unclear, but you can print the source code of your desired url/form to the console like this:
import java.io.*;
import java.net.*;
public class Client {
public String getHTML(String urlToRead) {
URL url;
HttpURLConnection conn;
BufferedReader rd;
String line;
String result = "";
try {
url = new URL(urlToRead);
conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod("GET");
rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
while ((line = rd.readLine()) != null) {
//basically makes a huge string
result += line;
}
rd.close();
} catch (Exception e) {
e.printStackTrace();
}
return result;
}
public static void main(String args[])
{
Client c = new Client();
System.out.println(c.getHTML("YOUR URL HERE"));
//prints source code to console
}
//from here, you need to know which item you want to do is at which index of the string
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With