I'm not sure if this is the right forum (
servlet would be my second guess). I try to write a servlet, that is receives a request, processes it and calls as a result an URL to retrieve information there. The system needs to pass on header fields from the original request. Retrieving the header was easy... I got stuck when setting the header to an HttpURLConnection. This is what I tried:
URL url = new URL(targetURL);
HttpURLConnection con = (HttpURLConnection) url.openConnection();
// Set the header
con.setRequestProperty("DisplayScheme","Winter");
con.setRequestProperty("LTPAToken",curUserToken);
// Post data
OutputStream out = connection.getOutputStream();
out.write(PayLoad.getBytes());
// Read the response;
String resultData = readURLResponse(con); // readURLResponse gets back
In general it returns anwers, but seems not to post the HTTP Header set with the setRequestProperty command. I'm sure it's a case of a
java rookie missing out something.
Any hint?
:-) stw