Results 1 to 2 of 2
- 12-14-2012, 06:02 AM #1
Member
- Join Date
- Dec 2012
- Posts
- 4
- Rep Power
- 0
Please Help: Java Applet 411 Length Required
I am new to Java. I wrote an applet that sends results (int w and int p) to a server, and I get the "411 Length Required" error. What am I doing wrong? How do I set a Content-Length?
This is the method that communicates with the server:
Java Code:public void sendPoints1(int w, int p){ try { String url = "http://somename.com:309/api/Results"; String charset = "UTF-8"; String query = String.format("?key=%s&value=%s", URLEncoder.encode(String.valueOf(w), charset), URLEncoder.encode(String.valueOf(p), charset)); String length = String.valueOf((url + query).getBytes("UTF-8").length); HttpURLConnection connection = (HttpURLConnection) new URL(url + query).openConnection(); connection.setRequestMethod("POST"); connection.setRequestProperty("Content-Length", length); connection.connect(); System.out.println("Responce Code: " + connection.getResponseCode()); System.out.println("Responce Message: " + connection.getResponseMessage()); } catch (Exception e) { System.err.println(e.getMessage()); } }
-
Re: Please Help: Java Applet 411 Length Required
How is this different from your previous same question? Locking this as duplicate. Please re-read the forum rules regarding duplicate posts.
Similar Threads
-
Applet Expand Collpse Help Required
By sarfrazasghar in forum Java AppletsReplies: 0Last Post: 11-07-2012, 08:44 AM -
Difference between length() and length
By mitra in forum New To JavaReplies: 7Last Post: 07-28-2011, 12:46 AM -
java Array.length property
By X-ion in forum New To JavaReplies: 0Last Post: 04-07-2010, 08:45 AM -
Help required: regarding java.net.URL api
By tarzan007 in forum New To JavaReplies: 3Last Post: 11-07-2007, 04:46 AM


LinkBack URL
About LinkBacks

Bookmarks