Results 1 to 2 of 2
  1. #1
    psdev is offline Member
    Join Date
    Dec 2012
    Rep Power

    Default 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 = "";
                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.setRequestProperty("Content-Length", length);
                System.out.println("Responce Code:    " + connection.getResponseCode());
                System.out.println("Responce Message: " + connection.getResponseMessage());
            } catch (Exception e) {

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Blog Entries
    Rep Power

    Default 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

  1. Applet Expand Collpse Help Required
    By sarfrazasghar in forum Java Applets
    Replies: 0
    Last Post: 11-07-2012, 08:44 AM
  2. Difference between length() and length
    By mitra in forum New To Java
    Replies: 7
    Last Post: 07-28-2011, 12:46 AM
  3. java Array.length property
    By X-ion in forum New To Java
    Replies: 0
    Last Post: 04-07-2010, 08:45 AM
  4. Help required: regarding api
    By tarzan007 in forum New To Java
    Replies: 3
    Last Post: 11-07-2007, 04:46 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts