GET-POST seems to be an issue here indeed. However,after adaptation
according to your suggestions, I still get a 500-error, from the W3C
site as well as my localhost.
Further below is the relevant piece of source code.
Firefox has this plug-in to invesxtigate HTTP data sent. this gives
the following when using the url :
http://jigsaw.w3.org/css-validator/validator?text=h2{margin-left:23px;}
=========================================
http://jigsaw.w3.org/css-validator/validator
POST /css-validator/validator HTTP/1.1
Host: jigsaw.w3.org
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US;
rv:1.9.1.7) Gecko/20091221 Firefox/3.5.7 (.NET CLR 3.5.30729)
Accept:
text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
Referer:
http://jigsaw.w3.org/css-validator/
Content-Type: multipart/form-data;
boundary=---------------------------114782935826962
Content-Length: 666
-----------------------------114782935826962
Content-Disposition: form-data; name="text"
h2{margin-left:23px;}
-----------------------------114782935826962
Content-Disposition: form-data; name="profile"
css21
-----------------------------114782935826962
Content-Disposition: form-data; name="usermedium"
all
-----------------------------114782935826962
Content-Disposition: form-data; name="type"
none
-----------------------------114782935826962
Content-Disposition: form-data; name="warning"
1
-----------------------------114782935826962
Content-Disposition: form-data; name="lang"
en
-----------------------------114782935826962--
=======================================
the relevant piece of my source is this:
public class URLConnectionTest
{
public static void main(String[] args)
{
try
{
String urlName =
"
http://jigsaw.w3.org/css-validator/validator";
URL url = new URL(urlName);
HttpURLConnection con = (HttpURLConnection)
url.openConnection();
con.setRequestMethod("POST");
con.setDoOutput(true);
PrintWriter os = new PrintWriter(con.getOutputStream());
os.print("text="+ URLEncoder.encode("h2{margin-left:34px;}", "UTF-8")
+ "&" );
os.print("profile"+ URLEncoder.encode("css21", "UTF-8") +
"&" );
os.print("usermedium="+ URLEncoder.encode("all", "UTF-8")
+ "&" );
os.print("type="+ URLEncoder.encode("none", "UTF-8") + "&"
);
os.print("warning="+ URLEncoder.encode("1", "UTF-8") + "&"
);
os.print("lang="+ URLEncoder.encode("en", "UTF-8") );
os.close();
// print header fields
int n = 1;
String key;
while ((key = con.getHeaderFieldKey(n)) != null)
{
String value = con.getHeaderField(n);
System.out.println(key + ": " + value);
n++;
}
// print convenience functions
System.out.println("----------");
System.out.println("getContentType: "
+ con.getContentType());
System.out.println("getContentLength: "
+ con.getContentLength());
System.out.println("getContentEncoding: "
+ con.getContentEncoding());
System.out.println("getDate: "
+ con.getDate());
System.out.println("getExpiration: "
+ con.getExpiration());
System.out.println("getLastModifed: "
+ con.getLastModified());
System.out.println("----------");
BufferedReader in = new BufferedReader(new
InputStreamReader(con.getInputStream()));
// print first ten lines of contents
String line;
n = 1;
while ((line = in.readLine()) != null && n <= 100)
{
System.out.println(line);
n++;
}
if (line != null) System.out.println(". . .");
}
catch (IOException exception)
{
exception.printStackTrace();
}
}